RPC returning table alias now works for pg 11/12 (#2737)

The new LATERAL query used for calling the function, introduced on
https://github.com/PostgREST/postgrest/pull/2677, failed on functions
that returned a domain like `CREATE DOMAIN projects_domain AS projects`.

Work around that by changing the query conditionally, by
obtaining a bool that represents the composite alias on the SchemaCache
and only do this on pg 11 and 12.
This commit is contained in:
Steve Chavez
2023-04-05 15:34:41 -05:00
committed by GitHub
parent 16f2849724
commit acf62320ef
8 changed files with 39 additions and 25 deletions
+2 -3
View File
@@ -15,7 +15,7 @@ import Text.Heredoc
import PostgREST.Config.PgVersion (PgVersion, pgVersion100,
pgVersion109, pgVersion110,
pgVersion112, pgVersion114,
pgVersion130, pgVersion140)
pgVersion140)
import Protolude hiding (get)
import SpecHelper
@@ -376,8 +376,7 @@ spec actualPgVersion =
]|]
{ matchHeaders = [matchContentTypeJson] }
-- https://github.com/PostgREST/postgrest/pull/2677#issuecomment-1444976849
when (actualPgVersion >= pgVersion130) $
when (actualPgVersion >= pgVersion110) $
it "can embed if rpc returns domain of table type" $ do
post "/rpc/getproject_domain?select=id,name,client:clients(id),tasks(id)"
[json| { "id": 1} |]