test: spread embed disambiguates 2 fks on junction
This commit is contained in:
committed by
Steve Chavez
parent
cb99270a8f
commit
60c0c11c1d
@@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
+ On a many-to-one or one-to-one relationship, you can order a parent by a child column `/projects?select=*,clients(*)&order=clients(name).desc.nullsfirst`
|
+ On a many-to-one or one-to-one relationship, you can order a parent by a child column `/projects?select=*,clients(*)&order=clients(name).desc.nullsfirst`
|
||||||
- #1233, Allow spreading embedded resources - @steve-chavez
|
- #1233, Allow spreading embedded resources - @steve-chavez
|
||||||
+ On a many-to-one or one-to-one relationship, you can unnest a json object with `/projects?select=*,..clients(client_name:name)`
|
+ On a many-to-one or one-to-one relationship, you can unnest a json object with `/projects?select=*,..clients(client_name:name)`
|
||||||
|
+ Allows disambiguating an embed that has a many-to-many relationship using two foreign keys on a junction
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -68,10 +68,8 @@ spec =
|
|||||||
, matchHeaders = [matchContentTypeJson]
|
, matchHeaders = [matchContentTypeJson]
|
||||||
}
|
}
|
||||||
|
|
||||||
it "errs when there are more than two fks on a junction table(currently impossible to disambiguate, only choice is to split the table)" $
|
it "errs when there are more than two fks on a junction table but it can be disambiguated with spread embeds" $ do
|
||||||
-- We have 4 possibilities for doing the junction JOIN here.
|
-- We have 4 possibilities for doing the junction JOIN here.
|
||||||
-- This could be solved by specifying two additional fks, like whatev_projects!fk1!fk2(*)
|
|
||||||
-- If the need arises this capability can be added later without causing a breaking change
|
|
||||||
get "/whatev_sites?select=*,whatev_projects(*)" `shouldRespondWith`
|
get "/whatev_sites?select=*,whatev_projects(*)" `shouldRespondWith`
|
||||||
[json|
|
[json|
|
||||||
{
|
{
|
||||||
@@ -105,6 +103,11 @@ spec =
|
|||||||
{ matchStatus = 300
|
{ matchStatus = 300
|
||||||
, matchHeaders = [matchContentTypeJson]
|
, matchHeaders = [matchContentTypeJson]
|
||||||
}
|
}
|
||||||
|
-- Each of those 4 possibilities can be done with spread embeds, by following the details in the error above
|
||||||
|
get "/whatev_sites?select=*,whatev_jobs!site_id_1(..whatev_projects!project_id_1(*))" `shouldRespondWith` [json|[]|]
|
||||||
|
get "/whatev_sites?select=*,whatev_jobs!site_id_1(..whatev_projects!project_id_2(*))" `shouldRespondWith` [json|[]|]
|
||||||
|
get "/whatev_sites?select=*,whatev_jobs!site_id_2(..whatev_projects!project_id_1(*))" `shouldRespondWith` [json|[]|]
|
||||||
|
get "/whatev_sites?select=*,whatev_jobs!site_id_2(..whatev_projects!project_id_2(*))" `shouldRespondWith` [json|[]|]
|
||||||
|
|
||||||
it "errs on an ambiguous embed that has two one-to-one relationships" $
|
it "errs on an ambiguous embed that has two one-to-one relationships" $
|
||||||
get "/first?select=second(*)" `shouldRespondWith`
|
get "/first?select=second(*)" `shouldRespondWith`
|
||||||
|
|||||||
Reference in New Issue
Block a user