Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested backrefs and arrays #651

Closed
Tracked by #161
sirex opened this issue Jun 13, 2024 · 0 comments · Fixed by #645
Closed
Tracked by #161

Nested backrefs and arrays #651

sirex opened this issue Jun 13, 2024 · 0 comments · Fixed by #645

Comments

@sirex
Copy link
Collaborator

sirex commented Jun 13, 2024

When a property is a part of an array or backref, then property.source
must be relative to property.source of array property.

For example, if we have following XML data:

<root>
    <object id="1">
        <fact id="1">
            <doc id="1" />
            <doc id="2" />
        </fact>
        <fact id="2">
            <doc id="3" />
            <doc id="4" />
        </fact>
    </object>
</root>

The manifest table should be:

model   property            type        ref         source
Object                                  id          root/object
        id                  integer                 @id
        facts[]             backref     Fact        fact
        facts[].id          backref                 @id   
        facts[].docs[]      backref     Document    doc
        facts[].docs[].id   backref                 @id
Fact                                    id          root/object/fact
        id                  integer                 @id
        object              ref         Object      ../@id
Document                                id          root/object/fact/doc
        id                  integer                 @id
        fact                ref         Fact        ../@id

Object/facts[].id property has @id in source, which is relative to source of Object/facts[].

Similar, but not exactly the same situation with tabular data, for example if we have following table:

object  fact  doc       
1       1     1
1       1     2
1       2     3
1       2     4

Then, manifest table would be:

model   property            type        ref         source
Object                                  id          table
        id                  integer                 object
        facts[]             backref     Fact        fact
        facts[].id          backref                 fact
        facts[].docs[]      backref     Document    doc
        facts[].docs[].id   backref                 doc
Fact                                    id          table
        id                  integer                 fact
        object              ref         Object      object
Document                                id          table
        id                  integer                 doc
        fact                ref         Fact        fact

In both cases (XML and tabular), UAPI JSON result for Object should be:

{
    "_type": "Object",
    "id": 1,
    "facts": [
        {
            "_type": "Fact",
            "id": 1,
            "docs": [
                {
                    "_type": "Document",
                    "id": 1,
                },
                {
                    "_type": "Document",
                    "id": 2,
                },
            ]
        },
        {
            "_type": "Fact",
            "id": 2,
            "docs": [
                {
                    "_type": "Document",
                    "id": 3,
                },
                {
                    "_type": "Document",
                    "id": 4,
                },
            ]
        }
    ],
}

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants