Fix unique foreign key in view (#1395)
This commit is contained in:
@@ -1112,3 +1112,12 @@ spec actualPgVersion = do
|
||||
|
||||
it "cannot use ltree(in public schema) extension operators if no extra search path added" $
|
||||
get "/ltree_sample?path=cd.Top.Science.Astronomy" `shouldRespondWith` 400
|
||||
|
||||
context "VIEW that has a source FK based on a UNIQUE key" $
|
||||
it "can be embedded" $
|
||||
get "/referrals?select=site,link:pages(url)" `shouldRespondWith`
|
||||
[json| [
|
||||
{"site":"github.com", "link":{"url":"http://postgrest.org/en/v6.0/api.html"}},
|
||||
{"site":"hub.docker.com", "link":{"url":"http://postgrest.org/en/v6.0/admin.html"}}
|
||||
]|]
|
||||
{ matchHeaders = [matchContentTypeJson] }
|
||||
|
||||
@@ -231,6 +231,23 @@ spec = do
|
||||
]
|
||||
|]
|
||||
|
||||
describe "VIEW that has a source FK based on a UNIQUE key" $
|
||||
|
||||
it "includes fk description" $ do
|
||||
r <- simpleBody <$> get "/"
|
||||
|
||||
let referralLink = r ^? key "definitions" . key "referrals" . key "properties" . key "link"
|
||||
|
||||
liftIO $
|
||||
referralLink `shouldBe` Just
|
||||
[aesonQQ|
|
||||
{
|
||||
"format": "integer",
|
||||
"type": "integer",
|
||||
"description": "Note:\nThis is a Foreign Key to `pages.link`.<fk table='pages' column='link'/>"
|
||||
}
|
||||
|]
|
||||
|
||||
describe "PostgreSQL to Swagger Type Mapping" $ do
|
||||
|
||||
it "character varying to string" $ do
|
||||
|
||||
Reference in New Issue
Block a user