fix: Fix ordering with mutation queries

This commit is contained in:
Taimoor Zaeem
2025-03-17 14:13:34 +01:00
committed by Steve Chavez
parent 5ff51de36f
commit fc35d6d0f8
8 changed files with 97 additions and 4 deletions
+24
View File
@@ -526,3 +526,27 @@ spec =
}
get "/UnitTest?idUnitTest=eq.1" `shouldRespondWith`
[json| [ { "idUnitTest": 1, "nameUnitTest": "unit test 1" } ]|]
context "with ordering" $ do
it "works with request method PUT and embedded resource" $
request methodPut "/web_content?id=eq.0&select=id,name,web_content(name)&web_content.order=name.asc"
[("Prefer", "return=representation")]
[json|{ "id": 0, "name": "tardis-upserted", "p_web_id": 5 }|]
`shouldRespondWith`
[json|
[ { "id": 0, "name": "tardis-upserted", "web_content": [ { "name": "bar" }, { "name": "fezz" }, { "name": "foo" } ]} ]
|]
{ matchStatus = 200
, matchHeaders = [matchContentTypeJson, "Preference-Applied" <:> "return=representation"]
}
it "works with batch upserts and embedded resource" $
request methodPost "/artists?select=id,name,albums(title)&order=id.desc"
[("Prefer", "return=representation"), ("Prefer", "resolution=merge-duplicates")]
[json| [{ "id": 1, "name": "duster-updated" },
{ "id": 2, "name": "bcnr-updated" }] |]
`shouldRespondWith`
[json| [{"id":2,"name":"bcnr-updated","albums":[{"title": "ants from up above"}]}, {"id":1,"name":"duster-updated","albums":[{"title": "stratosphere"}, {"title": "contemporary movement"}]}] |]
{ matchStatus = 200
, matchHeaders = [matchContentTypeJson]
}