-
-
Notifications
You must be signed in to change notification settings - Fork 158
Update one-to-many through PATCH on resource not working #492
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
Comments
maurei
added a commit
to wisepotato/JsonApiDotNetCore
that referenced
this issue
Apr 11, 2019
maurei
added a commit
to wisepotato/JsonApiDotNetCore
that referenced
this issue
Apr 11, 2019
This was referenced Apr 11, 2019
Merged
jaredcnance
added a commit
that referenced
this issue
Apr 13, 2019
maurei
added a commit
to wisepotato/JsonApiDotNetCore
that referenced
this issue
Apr 15, 2019
There was an additional issue related to entity tracking that caused an error when performing a complete replacement with a new collection that contained an element that was already in the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
A core feature of the spec is currently not supported:
Cause of the problem
Because of incomplete information on
_jsonApiContext
in the case ofone-to-many
, which is set in theJsonApiDeserializer
, theDefaultEntityRepository
does not attempt to update such relationships. Details:one-to-one
, theJsonApiDeserializer
adds meta info about this to_jsonApiContext.RelationshipsToUpdate
right here in the SetHasOneRelationship method.one-to-many
: in the SetHasManyRelationship method, only_jsonApiContext.HasManyRelationshipPointers
are updated, which is not enough.one-to-many
relationships if they were included in_jsonApiContext.RelationshipsToUpdate
.AttachRelationships(oldEntity)
is fired beforerelationship.Key.SetValue(oldEntity, relationship.Value);
is called, so any updates to the relations are currently not tracked.A complication: the request above should perform a complete replace. This means that before updating the
Author.BookId
to its new value, the foreign keys of all previousBook
s for that author should be set to null (and an error should be thrown it is non-nullable).Solution
hasManyAttr
value to theRelationshipsToUpdate
dictionary in theJsonApiDeserializer
right here.AttachRelationships(oldEntity)
before actually setting the new relationship collection.Note: the same issue exists for
many-to-many
, but it requires a different fix. Will address this in a separate issue.Environment
The text was updated successfully, but these errors were encountered: