From 033f3d61cebb654138f5f3634435e6c4b0e131e6 Mon Sep 17 00:00:00 2001 From: kraftwerk28 Date: Tue, 6 Sep 2022 20:16:11 +0300 Subject: [PATCH 1/6] server: return single object from non-SETOF SQL functions --- .../src-lib/Hasura/Backends/Postgres/DDL/BoolExp.hs | 12 +++++++----- .../Hasura/Backends/Postgres/DDL/ComputedField.hs | 4 +++- .../Hasura/Backends/Postgres/Instances/Types.hs | 1 + .../Hasura/Backends/Postgres/Types/ComputedField.hs | 2 ++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/server/src-lib/Hasura/Backends/Postgres/DDL/BoolExp.hs b/server/src-lib/Hasura/Backends/Postgres/DDL/BoolExp.hs index c6260b02a193a..07e0d65175169 100644 --- a/server/src-lib/Hasura/Backends/Postgres/DDL/BoolExp.hs +++ b/server/src-lib/Hasura/Backends/Postgres/DDL/BoolExp.hs @@ -313,16 +313,18 @@ buildComputedFieldBooleanExp boolExpResolver rhsParser rootFieldInfoMap colInfoM [] -> do let hasuraSession = _berpSessionValue rhsParser computedFieldFunctionArgs = flip FunctionArgsExp mempty $ PG.fromComputedFieldImplicitArguments hasuraSession _cffComputedFieldImplicitArgs + cfbeFromTable tableName = do + tableBoolExp <- decodeValue colVal + tableFieldInfoMap <- askFieldInfoMapSource tableName + annTableBoolExp <- (getBoolExpResolver boolExpResolver) rhsParser tableFieldInfoMap tableFieldInfoMap $ unBoolExp tableBoolExp + pure $ CFBETable tableName annTableBoolExp AnnComputedFieldBoolExp _cfiXComputedFieldInfo _cfiName _cffName computedFieldFunctionArgs <$> case _cfiReturnType of CFRScalar scalarType -> CFBEScalar <$> parseBoolExpOperations (_berpValueParser rhsParser) rootFieldInfoMap colInfoMap (ColumnReferenceComputedField _cfiName scalarType) colVal - CFRSetofTable table -> do - tableBoolExp <- decodeValue colVal - tableFieldInfoMap <- askFieldInfoMapSource table - annTableBoolExp <- (getBoolExpResolver boolExpResolver) rhsParser tableFieldInfoMap tableFieldInfoMap $ unBoolExp tableBoolExp - pure $ CFBETable table annTableBoolExp + CFRTable t -> cfbeFromTable t + CFRSetofTable t -> cfbeFromTable t _ -> throw400 UnexpectedPayload diff --git a/server/src-lib/Hasura/Backends/Postgres/DDL/ComputedField.hs b/server/src-lib/Hasura/Backends/Postgres/DDL/ComputedField.hs index c731bcbb44228..3b7052cf20877 100644 --- a/server/src-lib/Hasura/Backends/Postgres/DDL/ComputedField.hs +++ b/server/src-lib/Hasura/Backends/Postgres/DDL/ComputedField.hs @@ -133,7 +133,9 @@ buildComputedFieldInfo trackedTables table _tableColumns computedField definitio MV.dispute $ pure $ CFVEReturnTableNotFound returnTable - pure $ PG.CFRSetofTable returnTable + pure $ if rfiReturnsSet rawFunctionInfo + then PG.CFRSetofTable returnTable + else PG.CFRTable returnTable else do let scalarType = _qptName functionReturnType unless (isBaseType functionReturnType) $ diff --git a/server/src-lib/Hasura/Backends/Postgres/Instances/Types.hs b/server/src-lib/Hasura/Backends/Postgres/Instances/Types.hs index 8bb57b54de012..cfb5558800b6e 100644 --- a/server/src-lib/Hasura/Backends/Postgres/Instances/Types.hs +++ b/server/src-lib/Hasura/Backends/Postgres/Instances/Types.hs @@ -146,6 +146,7 @@ instance computedFieldReturnType = \case Postgres.CFRScalar scalarType -> ReturnsScalar scalarType Postgres.CFRSetofTable table -> ReturnsTable table + Postgres.CFRTable table -> ReturnsTable table fromComputedFieldImplicitArguments = Postgres.fromComputedFieldImplicitArguments tableGraphQLName = Postgres.qualifiedObjectToName diff --git a/server/src-lib/Hasura/Backends/Postgres/Types/ComputedField.hs b/server/src-lib/Hasura/Backends/Postgres/Types/ComputedField.hs index 9fa2ae3b4bb35..719d7e5776a3e 100644 --- a/server/src-lib/Hasura/Backends/Postgres/Types/ComputedField.hs +++ b/server/src-lib/Hasura/Backends/Postgres/Types/ComputedField.hs @@ -9,6 +9,7 @@ module Hasura.Backends.Postgres.Types.ComputedField fromComputedFieldImplicitArguments, ComputedFieldReturn (..), _CFRScalar, + _CFRTable, _CFRSetofTable, ) where @@ -108,6 +109,7 @@ fromComputedFieldImplicitArguments sess _ = [AESession sess, AETableRow] data ComputedFieldReturn = CFRScalar PGScalarType + | CFRTable QualifiedTable | CFRSetofTable QualifiedTable deriving (Show, Eq, Generic) From f06182728eb388079d7962f0a688f4deb1ed4d4b Mon Sep 17 00:00:00 2001 From: kraftwerk28 Date: Fri, 3 Mar 2023 03:07:27 +0200 Subject: [PATCH 2/6] server: filter null values in pg function result --- .../Hasura/Backends/Postgres/SQL/DML.hs | 4 ++-- .../Hasura/Backends/Postgres/Schema/Select.hs | 18 ++++++++++++++++++ .../Translate/Select/Internal/Process.hs | 9 +++++++-- .../Backends/Postgres/Translate/Types.hs | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/server/src-lib/Hasura/Backends/Postgres/SQL/DML.hs b/server/src-lib/Hasura/Backends/Postgres/SQL/DML.hs index 15fbf86194d77..6c9480b3be19f 100644 --- a/server/src-lib/Hasura/Backends/Postgres/SQL/DML.hs +++ b/server/src-lib/Hasura/Backends/Postgres/SQL/DML.hs @@ -14,10 +14,10 @@ module Hasura.Backends.Postgres.SQL.DML Extractor (..), FromExp (..), FromItem (..), - FunctionAlias (FunctionAlias), + FunctionAlias (FunctionAlias, _faIdentifier), FunctionDefinitionListItem (..), FunctionArgs (FunctionArgs), - FunctionExp (FunctionExp), + FunctionExp (FunctionExp, feAlias), GroupByExp (GroupByExp), HavingExp (HavingExp), JoinCond (..), diff --git a/server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs b/server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs index 09f6cfbf12df2..f0b408d4411ed 100644 --- a/server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs +++ b/server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs @@ -240,6 +240,24 @@ computedFieldPG ComputedFieldInfo {..} parentTable tableInfo = runMaybeT do ) dummyParser <- lift $ columnParser @('Postgres pgKind) (ColumnScalar scalarReturnType) (G.Nullability True) pure $ P.selection fieldName fieldDescription fieldArgsParser dummyParser + Postgres.CFRTable tableName -> do + otherTableInfo <- lift $ askTableInfo tableName + remotePerms <- hoistMaybe $ tableSelectPermissions roleName otherTableInfo + selectionSetParser <- MaybeT (fmap (P.multiple . P.nonNullableParser) <$> tableSelectionSet otherTableInfo) + let fieldArgsParser = functionArgsParser + pure $ + P.subselection fieldName fieldDescription fieldArgsParser selectionSetParser + <&> \(functionArgs', fields) -> + IR.AFComputedField _cfiXComputedFieldInfo _cfiName $ + IR.CFSTable JASSingleObject $ + IR.AnnSelectG + { IR._asnFields = fields, + IR._asnFrom = IR.FromFunction (_cffName _cfiFunction) functionArgs' Nothing, + IR._asnPerm = tablePermissionsInfo remotePerms, + IR._asnArgs = noSelectArgs, + IR._asnStrfyNum = stringifyNumbers, + IR._asnNamingConvention = Just tCase + } Postgres.CFRSetofTable tableName -> do otherTableInfo <- lift $ askTableInfo tableName remotePerms <- hoistMaybe $ tableSelectPermissions roleName otherTableInfo diff --git a/server/src-lib/Hasura/Backends/Postgres/Translate/Select/Internal/Process.hs b/server/src-lib/Hasura/Backends/Postgres/Translate/Select/Internal/Process.hs index ad83eb2618695..5cbdc6f7d49d0 100644 --- a/server/src-lib/Hasura/Backends/Postgres/Translate/Select/Internal/Process.hs +++ b/server/src-lib/Hasura/Backends/Postgres/Translate/Select/Internal/Process.hs @@ -342,10 +342,15 @@ processAnnFields sourcePrefix fieldAlias similarArrFields annFields tCase = do fieldName PLSQNotRequired sel - let computedFieldTableSetSource = ComputedFieldTableSetSource fieldName selectSource + let selectSourceWithoutNulls = + case selectSource of + SelectSource {_ssFrom = S.FIFunc (S.FunctionExp {S.feAlias = Just (S.FunctionAlias {S._faIdentifier = fnIden})})} -> + selectSource {_ssWhere = S.BENotNull $ S.SERowIdentifier $ S.getTableAlias fnIden} + _ -> selectSource + computedFieldTableSetSource = ComputedFieldTableSetSource fieldName selectSourceWithoutNulls extractor = asJsonAggExtr selectTy (S.toColumnAlias fieldName) PLSQNotRequired $ - orderByForJsonAgg selectSource + orderByForJsonAgg selectSourceWithoutNulls pure ( computedFieldTableSetSource, extractor, diff --git a/server/src-lib/Hasura/Backends/Postgres/Translate/Types.hs b/server/src-lib/Hasura/Backends/Postgres/Translate/Types.hs index fb25bd79545b8..4d0bdf68d436b 100644 --- a/server/src-lib/Hasura/Backends/Postgres/Translate/Types.hs +++ b/server/src-lib/Hasura/Backends/Postgres/Translate/Types.hs @@ -18,7 +18,7 @@ module Hasura.Backends.Postgres.Translate.Types SelectNode (SelectNode), SelectSlicing (SelectSlicing, _ssLimit, _ssOffset), SelectSorting (..), - SelectSource (SelectSource, _ssPrefix), + SelectSource (SelectSource, _ssPrefix, _ssWhere, _ssFrom), SortingAndSlicing (SortingAndSlicing), SourcePrefixes (..), SimilarArrayFields, From 9ecfd85803d4412ce0eccf9ed6e0b75adfbbfe5a Mon Sep 17 00:00:00 2001 From: kraftwerk28 Date: Mon, 6 Mar 2023 03:09:53 +0200 Subject: [PATCH 3/6] fix: selection set parser for CFRTable should return T instead of [T] --- server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs | 2 +- server/src-lib/Hasura/RQL/IR/BoolExp.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs b/server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs index f0b408d4411ed..84c4018d00fde 100644 --- a/server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs +++ b/server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs @@ -243,7 +243,7 @@ computedFieldPG ComputedFieldInfo {..} parentTable tableInfo = runMaybeT do Postgres.CFRTable tableName -> do otherTableInfo <- lift $ askTableInfo tableName remotePerms <- hoistMaybe $ tableSelectPermissions roleName otherTableInfo - selectionSetParser <- MaybeT (fmap (P.multiple . P.nonNullableParser) <$> tableSelectionSet otherTableInfo) + selectionSetParser <- MaybeT (fmap P.nonNullableParser <$> tableSelectionSet otherTableInfo) let fieldArgsParser = functionArgsParser pure $ P.subselection fieldName fieldDescription fieldArgsParser selectionSetParser diff --git a/server/src-lib/Hasura/RQL/IR/BoolExp.hs b/server/src-lib/Hasura/RQL/IR/BoolExp.hs index bd8cc818328ca..d15c42435df4d 100644 --- a/server/src-lib/Hasura/RQL/IR/BoolExp.hs +++ b/server/src-lib/Hasura/RQL/IR/BoolExp.hs @@ -392,7 +392,7 @@ opExpDepCol = \case data ComputedFieldBoolExp (backend :: BackendType) scalar = -- | SQL function returning a scalar CFBEScalar [OpExpG backend scalar] - | -- | SQL function returning SET OF table + | -- | SQL function returning table or SETOF table CFBETable (TableName backend) (AnnBoolExp backend scalar) deriving (Functor, Foldable, Traversable, Generic) From 3dacc5b0fe800a7eaed4055346248e1a22321172 Mon Sep 17 00:00:00 2001 From: kraftwerk28 Date: Sun, 12 Mar 2023 02:11:23 +0200 Subject: [PATCH 4/6] feat(test): test non-SETOF computed field --- .../Test/Schema/ComputedFields/TableSpec.hs | 142 +++++++++++++++++- 1 file changed, 139 insertions(+), 3 deletions(-) diff --git a/server/lib/api-tests/src/Test/Schema/ComputedFields/TableSpec.hs b/server/lib/api-tests/src/Test/Schema/ComputedFields/TableSpec.hs index a2c357bbb4cf1..1e8ada58467c0 100644 --- a/server/lib/api-tests/src/Test/Schema/ComputedFields/TableSpec.hs +++ b/server/lib/api-tests/src/Test/Schema/ComputedFields/TableSpec.hs @@ -102,6 +102,11 @@ articleTable = Schema.VStr "Article 3 Title", Schema.VStr "Article 3 by Author 2, has search keyword", Schema.VInt 2 + ], + [ Schema.VInt 4, + Schema.VStr "Article 4 Title", + Schema.VStr "Article 4 by unknown author", + Schema.VInt 3 ] ] } @@ -112,6 +117,7 @@ postgresSetupFunctions :: TestEnvironment -> [Fixture.SetupAction] postgresSetupFunctions testEnv = let schemaName = Schema.getSchemaName testEnv articleTableSQL = unSchemaName schemaName <> ".article" + authorTableSQL = unSchemaName schemaName <> ".author" in [ Fixture.SetupAction { Fixture.setupAction = Postgres.run_ testEnv $ @@ -140,6 +146,34 @@ postgresSetupFunctions testEnv = $$ LANGUAGE sql STABLE; |], Fixture.teardownAction = \_ -> pure () + }, + Fixture.SetupAction + { Fixture.setupAction = + Postgres.run_ testEnv $ + [i| + CREATE FUNCTION #{ fetch_author schemaName }(article_row article, filter_author_id int) + RETURNS author AS $$ + SELECT * + FROM #{ authorTableSQL } + WHERE id = article_row.author_id AND id = filter_author_id + LIMIT 1 + $$ LANGUAGE sql STABLE; + |], + Fixture.teardownAction = \_ -> pure () + }, + Fixture.SetupAction + { Fixture.setupAction = + Postgres.run_ testEnv $ + [i| + CREATE FUNCTION #{ fetch_author_no_user_args schemaName }(article_row article) + RETURNS author AS $$ + SELECT * + FROM #{ authorTableSQL } + WHERE id = article_row.author_id + LIMIT 1 + $$ LANGUAGE sql STABLE; + |], + Fixture.teardownAction = \_ -> pure () } ] @@ -185,6 +219,14 @@ fetch_articles_no_user_args :: SchemaName -> T.Text fetch_articles_no_user_args schemaName = unSchemaName schemaName <> ".fetch_articles_no_user_args" +fetch_author :: SchemaName -> T.Text +fetch_author schemaName = + unSchemaName schemaName <> ".fetch_author" + +fetch_author_no_user_args :: SchemaName -> T.Text +fetch_author_no_user_args schemaName = + unSchemaName schemaName <> ".fetch_author_no_user_args" + setupMetadata :: TestEnvironment -> [Fixture.SetupAction] setupMetadata testEnvironment = let backendTypeMetadata = fromMaybe (error "Unknown backend") $ getBackendTypeConfig testEnvironment @@ -203,9 +245,9 @@ setupMetadata testEnvironment = "search_articles" [yaml| a_id: id |] [yaml| - name: article - dataset: *schemaName - |] + name: article + dataset: *schemaName + |] testEnvironment, Fixture.teardownAction = \_ -> pure () }, @@ -262,6 +304,36 @@ setupMetadata testEnvironment = selectPermissionColumns = (["id", "name"] :: [Text]) }, Fixture.teardownAction = \_ -> pure () + }, + Fixture.SetupAction + { Fixture.setupAction = + Schema.trackComputedField + source + articleTable + "fetch_author" + "author" + [yaml| a_id: id |] + [yaml| + name: author + dataset: *schemaName + |] + testEnvironment, + Fixture.teardownAction = \_ -> pure () + }, + Fixture.SetupAction + { Fixture.setupAction = + Schema.trackComputedField + source + articleTable + "fetch_author_no_user_args" + "author_no_args" + [yaml| a_id: id |] + [yaml| + name: author + dataset: *schemaName + |] + testEnvironment, + Fixture.teardownAction = \_ -> pure () } ] @@ -473,3 +545,67 @@ tests opts = do id: 2 title: Article 2 Title |] + + it "Query single nullable value for non-SETOF function" $ \testEnv -> do + let schemaName = Schema.getSchemaName testEnv + + shouldReturnYaml + opts + ( GraphqlEngine.postGraphql + testEnv + [graphql| + query { + #{schemaName}_article(order_by: {id: desc} limit: 2) { + id + title + author(args: {filter_author_id: 1}) { + id + name + } + } + } + |] + ) + [interpolateYaml| + data: + #{schemaName}_article: + - id: 4 + title: Article 4 Title + author: null + - id: 3 + title: Article 3 Title + author: null + |] + + it "Query single nullable value for non-SETOF function without arguments" $ \testEnv -> do + let schemaName = Schema.getSchemaName testEnv + + shouldReturnYaml + opts + ( GraphqlEngine.postGraphql + testEnv + [graphql| + query { + #{schemaName}_article(order_by: {id: desc} limit: 2) { + id + title + author_no_args { + id + name + } + } + } + |] + ) + [interpolateYaml| + data: + #{schemaName}_article: + - id: 4 + title: Article 4 Title + author_no_args: null + - id: 3 + title: Article 3 Title + author_no_args: + id: 2 + name: Author 2 + |] From 4354a5dec39efba8dba575405cb90e34042520ce Mon Sep 17 00:00:00 2001 From: kraftwerk28 Date: Sun, 12 Mar 2023 11:16:57 +0200 Subject: [PATCH 5/6] fix(server): make SETOF-table computed field non nullable and non-SETOF-table computed field nullable --- server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs b/server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs index 84c4018d00fde..d19c14fc67b00 100644 --- a/server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs +++ b/server/src-lib/Hasura/Backends/Postgres/Schema/Select.hs @@ -243,7 +243,7 @@ computedFieldPG ComputedFieldInfo {..} parentTable tableInfo = runMaybeT do Postgres.CFRTable tableName -> do otherTableInfo <- lift $ askTableInfo tableName remotePerms <- hoistMaybe $ tableSelectPermissions roleName otherTableInfo - selectionSetParser <- MaybeT (fmap P.nonNullableParser <$> tableSelectionSet otherTableInfo) + selectionSetParser <- MaybeT $ tableSelectionSet otherTableInfo let fieldArgsParser = functionArgsParser pure $ P.subselection fieldName fieldDescription fieldArgsParser selectionSetParser @@ -261,7 +261,7 @@ computedFieldPG ComputedFieldInfo {..} parentTable tableInfo = runMaybeT do Postgres.CFRSetofTable tableName -> do otherTableInfo <- lift $ askTableInfo tableName remotePerms <- hoistMaybe $ tableSelectPermissions roleName otherTableInfo - selectionSetParser <- MaybeT (fmap (P.multiple . P.nonNullableParser) <$> tableSelectionSet otherTableInfo) + selectionSetParser <- MaybeT (fmap (P.nonNullableParser . P.multiple . P.nonNullableParser) <$> tableSelectionSet otherTableInfo) selectArgsParser <- lift $ tableArguments otherTableInfo let fieldArgsParser = liftA2 (,) functionArgsParser selectArgsParser pure $ From de7f1f6d113be82afbe4b67592384154597b7e6a Mon Sep 17 00:00:00 2001 From: kraftwerk28 Date: Mon, 13 Mar 2023 00:00:27 +0200 Subject: [PATCH 6/6] fix(tests): write spec for BigQuery as well --- .../Test/Schema/ComputedFields/TableSpec.hs | 107 ++++++++++++++---- 1 file changed, 85 insertions(+), 22 deletions(-) diff --git a/server/lib/api-tests/src/Test/Schema/ComputedFields/TableSpec.hs b/server/lib/api-tests/src/Test/Schema/ComputedFields/TableSpec.hs index 1e8ada58467c0..af2c0686575f2 100644 --- a/server/lib/api-tests/src/Test/Schema/ComputedFields/TableSpec.hs +++ b/server/lib/api-tests/src/Test/Schema/ComputedFields/TableSpec.hs @@ -16,6 +16,7 @@ import Harness.Quoter.Graphql (graphql) import Harness.Quoter.Yaml (interpolateYaml, yaml) import Harness.Test.BackendType qualified as BackendType import Harness.Test.Fixture qualified as Fixture +import Harness.Test.FixtureName (backendTypesForFixture) import Harness.Test.Permissions (Permission (SelectPermission), SelectPermissionDetails (..), selectPermission) import Harness.Test.Permissions qualified as Permission import Harness.Test.Schema (SchemaName (..), Table (..), table) @@ -181,6 +182,7 @@ bigquerySetupFunctions :: TestEnvironment -> [Fixture.SetupAction] bigquerySetupFunctions testEnv = let schemaName = Schema.getSchemaName testEnv articleTableSQL = unSchemaName schemaName <> ".article" + authorTableSQL = unSchemaName schemaName <> ".author" in [ Fixture.SetupAction { Fixture.setupAction = BigQuery.run_ $ @@ -208,6 +210,39 @@ bigquerySetupFunctions testEnv = ) |], Fixture.teardownAction = \_ -> pure () + }, + Fixture.SetupAction + { Fixture.setupAction = + BigQuery.run_ $ + [i| + CREATE TABLE FUNCTION + #{ fetch_author schemaName }(a_id INT64, filter_author_id INT64) + AS + ( + SELECT au.* + FROM #{ authorTableSQL } as au + JOIN #{ articleTableSQL } as ar + ON ar.author_id = au.id + WHERE ar.id = a_id AND au.id = filter_author_id + ) + |], + Fixture.teardownAction = \_ -> pure () + }, + Fixture.SetupAction + { Fixture.setupAction = + BigQuery.run_ $ + [i| + CREATE TABLE FUNCTION + #{ fetch_author_no_user_args schemaName }(a_id INT64) + AS + ( + SELECT au.* FROM #{ authorTableSQL } AS au + JOIN #{ articleTableSQL } as ar + ON ar.author_id = au.id + WHERE ar.id = a_id + ) + |], + Fixture.teardownAction = \_ -> pure () } ] @@ -548,6 +583,7 @@ tests opts = do it "Query single nullable value for non-SETOF function" $ \testEnv -> do let schemaName = Schema.getSchemaName testEnv + TestEnvironment { fixtureName } = testEnv shouldReturnYaml opts @@ -566,19 +602,32 @@ tests opts = do } |] ) - [interpolateYaml| - data: - #{schemaName}_article: - - id: 4 - title: Article 4 Title - author: null - - id: 3 - title: Article 3 Title - author: null - |] + if Fixture.Postgres `elem` backendTypesForFixture fixtureName then + [interpolateYaml| + data: + #{schemaName}_article: + - id: 4 + title: Article 4 Title + author: null + - id: 3 + title: Article 3 Title + author: null + |] + else + [interpolateYaml| + data: + #{schemaName}_article: + - id: 4 + title: Article 4 Title + author: [] + - id: 3 + title: Article 3 Title + author: [] + |] it "Query single nullable value for non-SETOF function without arguments" $ \testEnv -> do let schemaName = Schema.getSchemaName testEnv + TestEnvironment { fixtureName } = testEnv shouldReturnYaml opts @@ -597,15 +646,29 @@ tests opts = do } |] ) - [interpolateYaml| - data: - #{schemaName}_article: - - id: 4 - title: Article 4 Title - author_no_args: null - - id: 3 - title: Article 3 Title - author_no_args: - id: 2 - name: Author 2 - |] + if Fixture.Postgres `elem` backendTypesForFixture fixtureName then + [interpolateYaml| + data: + #{schemaName}_article: + - id: 4 + title: Article 4 Title + author_no_args: null + - id: 3 + title: Article 3 Title + author_no_args: + id: 2 + name: Author 2 + |] + else + [interpolateYaml| + data: + #{schemaName}_article: + - id: 4 + title: Article 4 Title + author_no_args: [] + - id: 3 + title: Article 3 Title + author_no_args: + - id: 2 + name: Author 2 + |]