fix: prevent spread embed to use aggregates when disabled

This commit is contained in:
Laurence Isla
2024-08-21 16:56:32 -05:00
parent 9a079607dd
commit 3539aaff89
3 changed files with 28 additions and 3 deletions
@@ -166,3 +166,25 @@ disallowed =
}|]
{ matchStatus = 400
, matchHeaders = [matchContentTypeJson] }
it "prevents the use of aggregates on embedded relationships" $
get "/projects?select=name,project_invoices(invoice_total.sum())" `shouldRespondWith`
[json|{
"hint":null,
"details":null,
"code":"PGRST123",
"message":"Use of aggregate functions is not allowed"
}|]
{ matchStatus = 400
, matchHeaders = [matchContentTypeJson] }
it "prevents the use of aggregates on spread embeds" $
get "/project_invoices?select=...projects(id.count())" `shouldRespondWith`
[json|{
"hint":null,
"details":null,
"code":"PGRST123",
"message":"Use of aggregate functions is not allowed"
}|]
{ matchStatus = 400
, matchHeaders = [matchContentTypeJson] }