You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running into a case where PATCHing a record with a HasManyThrough relationship is failing to do a complete replacement, as per spec. Consider the classic example:
For whatever reason, it's not deleting the existing ArticleTag records before trying to insert new ones, e.g. If I already have tag#2 assigned to article#1, it tries to re-insert the record, leading to a primary key violation in the ArticleTag table.
For the record, it works just fine if issuing a PATCH to articles/1/relationships/tags, like so:
...but ember-data really really wants to submit things all as one request, so here we are. :P
Poking around the source code a bit, looks there's a whole bunch of handling for this case in GenericProcessor that only seems to get used when entering the controller via PatchRelationshipsAsync -- i.e. if you start from PatchAsync, that workflow never handles it.
Having said that, there's a test here that looks like it should catch this -- I'm not totally sure why it works but my case doesn't just yet.
I'll see if I can do more spelunking soonish. Gotta get Docker to behave first. :P
Environment
JsonApiDotNetCore Version: 3.1.0-alpha3
Other Relevant Package Versions: N/A
The text was updated successfully, but these errors were encountered:
Reproduced & committed a failing test on this branch.
The gist: the existing m2m PATCH test creates an Article and a Tag in the database before running, but doesn't create any ArticleTags, so the PATCH is dealing with a blank slate. I created a second test (linked above) where the database has an existing ArticleTag, and sure enough, the PATCH fails with a duplicate primary key error.
Description
I'm running into a case where PATCHing a record with a HasManyThrough relationship is failing to do a complete replacement, as per spec. Consider the classic example:
For whatever reason, it's not deleting the existing ArticleTag records before trying to insert new ones, e.g. If I already have tag#2 assigned to article#1, it tries to re-insert the record, leading to a primary key violation in the ArticleTag table.
For the record, it works just fine if issuing a PATCH to
articles/1/relationships/tags
, like so:...but
ember-data
really really wants to submit things all as one request, so here we are. :PPoking around the source code a bit, looks there's a whole bunch of handling for this case in GenericProcessor that only seems to get used when entering the controller via
PatchRelationshipsAsync
-- i.e. if you start fromPatchAsync
, that workflow never handles it.Having said that, there's a test here that looks like it should catch this -- I'm not totally sure why it works but my case doesn't just yet.
I'll see if I can do more spelunking soonish. Gotta get Docker to behave first. :P
Environment
The text was updated successfully, but these errors were encountered: