Skip to content

Change tracking for patch updates, to improve json:api spec compliance #704

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

Merged
merged 4 commits into from
Apr 13, 2020
Merged

Change tracking for patch updates, to improve json:api spec compliance #704

merged 4 commits into from
Apr 13, 2020

Conversation

bart-degreed
Copy link
Contributor

I have added some calculated properties to the examples, in order to have tests for:

  • nothing outside the patch request changed (returns empty data)
    • KebabCaseFormatterTests.KebabCaseFormatter_Update_IsUpdated has no side effects in updating KebabCasedModel attributes
    • ManyToManyTests.Can_Update_Many_To_Many has no side effects in updating Article tags
    • ManyToManyTests.Can_Update_Many_To_Many_With_Complete_Replacement has no side effects in updating Article tags
    • ManyToManyTests.Can_Update_Many_To_Many_With_Complete_Replacement_With_Overlap has no side effects in updating Article tags
  • exposed attribute that was not in PATCH request changed (returns attributes)
    • UpdatingDataTests.PatchResource_ModelWithEntityFrameworkInheritance_IsPatched updates User.Password property, which updates exposed LastPasswordChange attribute
    • UpdatingDataTests.Patch_Entity_With_HasMany_Does_Not_Include_Relationships updates Person.FirstName property, which updates exposed Initials attribute
    • TodoItemsControllerTests.Can_Patch_TodoItemWithNullable does not update exposed TodoItem.AlwaysChangingValue attribute
  • exposed attribute that was in PATCH request changed (returns attributes)
    • TodoItemsControllerTests.Can_Patch_TodoItem updates TodoItem.AlwaysChangingValue attribute

Also updated a few places where an empty list was allocated each time with a cached empty array instance.

Fixes #577.

I have added some calculated properties to the examples, in order to have tests for:
- nothing outside the patch request changed (returns empty data)
  - `KebabCaseFormatterTests.KebabCaseFormatter_Update_IsUpdated` has no side effects in updating `KebabCasedModel` attributes
  - `ManyToManyTests.Can_Update_Many_To_Many` has no side effects in updating `Article` tags
  - `ManyToManyTests.Can_Update_Many_To_Many_With_Complete_Replacement` has no side effects in updating `Article` tags
  - `ManyToManyTests.Can_Update_Many_To_Many_With_Complete_Replacement_With_Overlap` has no side effects in updating `Article` tags
- exposed attribute that was not in PATCH request changed (returns attributes)
  - `UpdatingDataTests.PatchResource_ModelWithEntityFrameworkInheritance_IsPatched` updates `User.Password` property, which updates exposed `LastPasswordChange` attribute
  - `UpdatingDataTests.Patch_Entity_With_HasMany_Does_Not_Include_Relationships` updates `Person.FirstName` property, which updates exposed `Initials` attribute
  - `TodoItemsControllerTests.Can_Patch_TodoItemWithNullable` does not update exposed `TodoItem.AlwaysChangingValue` attribute
- exposed attribute that was in PATCH request changed (returns attributes)
  - `TodoItemsControllerTests.Can_Patch_TodoItem` updates `TodoItem.AlwaysChangingValue` attribute

Also updated a few places where an empty list was allocated each time with a cached empty array instance.
@bart-degreed bart-degreed merged commit 74f32f7 into json-api-dotnet:master Apr 13, 2020
@bart-degreed bart-degreed deleted the patch-attr-change-detection branch April 13, 2020 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Response when updating attributes of resource not conform spec
2 participants