Skip to content
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

Bulk update #2311

Merged
merged 8 commits into from
Jun 16, 2022
Merged

Bulk update #2311

merged 8 commits into from
Jun 16, 2022

Conversation

steve-chavez
Copy link
Member

@steve-chavez steve-chavez commented Jun 12, 2022

Closes #1959.

TODO

  • Tests

Unnecessary because root filters don't have an EmbedPath(it's empty)
@steve-chavez steve-chavez marked this pull request as ready for review June 16, 2022 01:19
@steve-chavez steve-chavez merged commit 86574c8 into PostgREST:main Jun 16, 2022
@steve-chavez steve-chavez mentioned this pull request Jul 7, 2022
5 tasks
Comment on lines +391 to +401
it "does not work when no limit query or filter is given" $
request methodPatch "/limited_update_items"
[("Prefer", "tx=commit"), ("Prefer", "count=exact")]
[json| {"name": "updated-item"} |]
`shouldRespondWith`
""
{ matchStatus = 404
, matchHeaders = [ matchHeaderAbsent hContentType
, "Content-Range" <:> "*/0" ]
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error was just a lucky side-effect of #2343. This needs a clear error message plus a 422 status - like done for batch delete.

Comment on lines +638 to +650
request methodPatch "/bulk_update_items"
[("Prefer", "tx=commit")]
[json|[
{ "id": 1, "name": "item-1 - 1st", "observation": "Lost item" }
, { "id": 3, "name": "item-3 - 3rd", "observation": null }
]|]
`shouldRespondWith`
""
{ matchStatus = 204
, matchHeaders = [ matchHeaderAbsent hContentType
, "Content-Range" <:> "0-1/*"
, "Preference-Applied" <:> "tx=commit" ]
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the pks as filters without the option to reference other key in the body is too arbitrary. We need to be able to refer to every key, like bulk delete does.

For this, we'd need underscore operators.

@steve-chavez steve-chavez mentioned this pull request Aug 12, 2022
2 tasks
laurenceisla added a commit that referenced this pull request Aug 12, 2022
- Revert patch #2311
- Keep the refactor done to qsFiltersRoot
- Keep the refactor done to the items tables
- Add tests that now work with pg-safeupdate as a result
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.

Support proper bulk update via PATCH
2 participants