api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.44k stars 868 forks source link

Updating relations on ManyToMany relationship doesn't work #133

Closed Drachenkaetzchen closed 9 years ago

Drachenkaetzchen commented 9 years ago

I have a ManyToMany relation in my project. Serialization Groups are working as expected, however, when I try to PUT a new Unit, my new relations are ignored:

Request:

{
    "name": "test123",
    "prefixes": [
        {
            "@id": "/~felicitus/PartKeepr/web/app_dev.php/api/si_prefixes/12"
        }
    ]
}

Response:

{
    "@context": "/~felicitus/PartKeepr/web/app_dev.php/api/contexts/Unit",
    "@id": "/~felicitus/PartKeepr/web/app_dev.php/api/units/1",
    "@type": "Unit",
    "name": "test123",
    "symbol": "v",
    "prefixes": [
        {
            "@id": "/~felicitus/PartKeepr/web/app_dev.php/api/si_prefixes/8",
            "@type": "SiPrefix",
            "prefix": "kilo",
            "symbol": "k",
            "exponent": 3,
            "base": 0
        },
        {
            "@id": "/~felicitus/PartKeepr/web/app_dev.php/api/si_prefixes/11",
            "@type": "SiPrefix",
            "prefix": "-",
            "symbol": "",
            "exponent": 0,
            "base": 0
        },
        {
            "@id": "/~felicitus/PartKeepr/web/app_dev.php/api/si_prefixes/15",
            "@type": "SiPrefix",
            "prefix": "micro",
            "symbol": "μ",
            "exponent": -6,
            "base": 0
        }
    ]
}

I also tried passing @type, which didn't make any difference.

My Unit is here and my SiPrefix is here. The configuration is here. I hope it's not a PEBKAC.

Drachenkaetzchen commented 9 years ago

This is bogus, I simply didn't have an accessor for setting the prefixes. I wonder why the rest of the system did work previously ;)