Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

API fails when relationship has conflicting name #730

Closed
rijkvanzanten opened this issue Jan 25, 2019 · 4 comments
Closed

API fails when relationship has conflicting name #730

rijkvanzanten opened this issue Jan 25, 2019 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@rijkvanzanten
Copy link
Member

Bug Report

When a many to one is created where the field name also exists in the related table, the api stops returning the values for the related collection.

If you have the following setup:

broken_a
--------------------
id
text (varchar)

broken_b
--------------------
id
text (m2o)
relationship
--------------------
collection_many: broken_b
field_many: text
collection_one: broken_a

fetching items from broken_a directly now doesn't return any values anymore.

Other Context & Screenshots

I've provided an empty DB setup with an example of a working relationship and a broken one.

tables_dump_January_25_2019.sql.txt

Technical Details

API v7.0.15

@rijkvanzanten rijkvanzanten added the bug Something isn't working label Jan 25, 2019
@wellingguzman
Copy link
Contributor

I tested this locally, and it's working as expected. I cannot reproduce this issue.

Result:

GET http://localhost/_/items/broken_a

{
    "data": [
        {
            "id": 1,
            "text": "Item 1"
        },
        {
            "id": 2,
            "text": "Item 2"
        },
        {
            "id": 3,
            "text": "Item 3"
        }
    ]
}
GET http://localhost/_/items/broken_b

{
    "data": [
        {
            "id": 1,
            "text": 1
        },
        {
            "id": 2,
            "text": 2
        }
    ]
}
GET http://localhost/_/items/broken_b?fields=*.*

{
    "data": [
        {
            "id": 1,
            "text": {
                "id": 1,
                "text": "Item 1"
            }
        },
        {
            "id": 2,
            "text": {
                "id": 2,
                "text": "Item 2"
            }
        }
    ]
}

@wellingguzman wellingguzman added the not reproducible The developer couldn’t reproduce the bug label Jan 25, 2019
@wellingguzman
Copy link
Contributor

Oh!

GET http://localhost/_/items/broken_a?fields=*.*

{
    "data": [
        {
            "id": 1,
            "text": null
        },
        {
            "id": 2,
            "text": null
        },
        {
            "id": 3,
            "text": null
        }
    ]
}

I believe this is the one you are talking about.

@wellingguzman wellingguzman removed the not reproducible The developer couldn’t reproduce the bug label Jan 25, 2019
@rijkvanzanten
Copy link
Member Author

Yes!

@wellingguzman
Copy link
Contributor

This was fixed by 47d6aa3

By also checking that the field's collection name is the same as the relation's collection.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants