Ignore the Range header when the method is different than GET

fix: bug when using Range header on PATCH/DELETE
  - Fix the "message": "syntax error at or near \"RETURNING\"" error
  - Fix doing a limited update/delete when an order query parameter was present

breaking: The Range header is now only considered on GET requests and is ignored for any other method
  - Other methods should use the `limit/offset` query parameters for sub-ranges
  - PUT requests no longer return an error when this header is present
This commit is contained in:
Laurence Isla
2023-04-03 10:40:25 -05:00
committed by GitHub
parent 032f07f3f0
commit 1aed55be68
11 changed files with 291 additions and 109 deletions
+4 -4
View File
@@ -38,7 +38,7 @@ spec =
it "allows full table update if a filter is present" $
baseTable "safe_update_items" "id" tblDataBefore
`mutatesWith`
requestMutation methodPatch "/safe_update_items?id=gt.0" [json| {"name": "updated-item"} |]
requestMutation methodPatch "/safe_update_items?id=gt.0" mempty [json| {"name": "updated-item"} |]
`shouldMutateInto`
[json|[
{ "id": 1, "name": "updated-item", "observation": null }
@@ -61,7 +61,7 @@ spec =
it "allows full table delete if a filter is present" $
baseTable "safe_delete_items" "id" tblDataBefore
`mutatesWith`
requestMutation methodDelete "/safe_delete_items?id=gt.0" mempty
requestMutation methodDelete "/safe_delete_items?id=gt.0" mempty mempty
`shouldMutateInto`
[json|[]|]
@@ -72,7 +72,7 @@ disabledSpec =
it "works if no condition is present" $
baseTable "unsafe_update_items" "id" tblDataBefore
`mutatesWith`
requestMutation methodPatch "/unsafe_update_items" [json| {"name": "updated-item"} |]
requestMutation methodPatch "/unsafe_update_items" mempty [json| {"name": "updated-item"} |]
`shouldMutateInto`
[json|[
{ "id": 1, "name": "updated-item", "observation": null }
@@ -84,6 +84,6 @@ disabledSpec =
it "works if no condition is present" $
baseTable "unsafe_delete_items" "id" tblDataBefore
`mutatesWith`
requestMutation methodDelete "/unsafe_delete_items" mempty
requestMutation methodDelete "/unsafe_delete_items" mempty mempty
`shouldMutateInto`
[json|[]|]