feat: add one to one relationship for embedding
BREAKING CHANGE: For the cases where one to one relationships are detected, json objects will be returned instead of json arrays of length 1. If you wish to override this behavior, you can use computed relationships to return arrays again.
This commit is contained in:
committed by
Steve Chavez
parent
2afe13fa89
commit
c45e85c5a6
@@ -78,6 +78,32 @@ spec =
|
||||
, matchHeaders = ["Content-Range" <:> "*/*"]
|
||||
}
|
||||
|
||||
it "embeds an O2O relationship after delete" $ do
|
||||
request methodDelete "/students?id=eq.1&select=name,students_info(address)"
|
||||
[("Prefer", "return=representation")] ""
|
||||
`shouldRespondWith`
|
||||
[json|[
|
||||
{
|
||||
"name": "John Doe",
|
||||
"students_info":{"address":"Street 1"}
|
||||
}
|
||||
]|]
|
||||
{ matchStatus = 200,
|
||||
matchHeaders = [matchContentTypeJson]
|
||||
}
|
||||
request methodDelete "/students_info?id=eq.1&select=address,students(name)"
|
||||
[("Prefer", "return=representation")] ""
|
||||
`shouldRespondWith`
|
||||
[json|[
|
||||
{
|
||||
"address": "Street 1",
|
||||
"students":{"name": "John Doe"}
|
||||
}
|
||||
]|]
|
||||
{ matchStatus = 200,
|
||||
matchHeaders = [matchContentTypeJson]
|
||||
}
|
||||
|
||||
context "known route, no records matched" $
|
||||
it "includes [] body if return=rep" $
|
||||
request methodDelete "/items?id=eq.101"
|
||||
|
||||
Reference in New Issue
Block a user