mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-10-05 14:28:08 +03:00
Remove Identifier associated type family from Backend class (close #1758)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3096 GitOrigin-RevId: 03f218a76c5f333a77646a60c8c69767e2286ea6
This commit is contained in:
parent
44fa624ee9
commit
038a6113c3
@ -15,7 +15,6 @@ import Language.GraphQL.Draft.Syntax qualified as G
|
||||
instance Backend 'BigQuery where
|
||||
type SourceConfig 'BigQuery = BigQuery.BigQuerySourceConfig
|
||||
type SourceConnConfiguration 'BigQuery = BigQuery.BigQueryConnSourceConfig
|
||||
type Identifier 'BigQuery = Void
|
||||
type TableName 'BigQuery = BigQuery.TableName
|
||||
type FunctionName 'BigQuery = BigQuery.FunctionName
|
||||
type RawFunctionInfo 'BigQuery = Void
|
||||
|
@ -128,7 +128,7 @@ fromSelectRows annSelectG = do
|
||||
selectFrom <-
|
||||
case from of
|
||||
IR.FromTable qualifiedObject -> fromQualifiedTable qualifiedObject
|
||||
IR.FromIdentifier identifier -> pure $ FromIdentifier identifier
|
||||
IR.FromIdentifier identifier -> pure $ FromIdentifier $ IR.unFIIdentifier identifier
|
||||
IR.FromFunction {} -> refute $ pure FunctionNotSupported
|
||||
Args
|
||||
{ argsOrderBy,
|
||||
@ -270,7 +270,7 @@ fromSelectAggregate
|
||||
do
|
||||
selectFrom <- case from of
|
||||
IR.FromTable qualifiedObject -> fromQualifiedTable qualifiedObject
|
||||
IR.FromIdentifier identifier -> pure $ FromIdentifier identifier
|
||||
IR.FromIdentifier identifier -> pure $ FromIdentifier $ IR.unFIIdentifier identifier
|
||||
IR.FromFunction {} -> refute $ pure FunctionNotSupported
|
||||
-- Below: When we're actually a RHS of a query (of CROSS APPLY),
|
||||
-- then we'll have a LHS table that we're joining on. So we get the
|
||||
|
@ -475,7 +475,7 @@ mkSelect ::
|
||||
Fields (AnnFieldG 'MSSQL Void Expression) ->
|
||||
m Select
|
||||
mkSelect stringifyNum withAlias jsonAggSelect annFields = do
|
||||
let annSelect = IR.AnnSelectG annFields (IR.FromIdentifier withAlias) IR.noTablePermissions IR.noSelectArgs stringifyNum
|
||||
let annSelect = IR.AnnSelectG annFields (IR.FromIdentifier $ FIIdentifier withAlias) IR.noTablePermissions IR.noSelectArgs stringifyNum
|
||||
V.runValidate (runFromIr $ mkSQLSelect jsonAggSelect annSelect) `onLeft` (throw500 . tshow)
|
||||
|
||||
-- SELECT COUNT(*) AS "count" FROM [with_alias]
|
||||
|
@ -18,7 +18,6 @@ import Language.GraphQL.Draft.Syntax qualified as G
|
||||
instance Backend 'MSSQL where
|
||||
type SourceConfig 'MSSQL = MSSQL.MSSQLSourceConfig
|
||||
type SourceConnConfiguration 'MSSQL = MSSQL.MSSQLConnConfiguration
|
||||
type Identifier 'MSSQL = Text
|
||||
type TableName 'MSSQL = MSSQL.TableName
|
||||
type RawFunctionInfo 'MSSQL = Void
|
||||
type FunctionName 'MSSQL = MSSQL.FunctionName
|
||||
|
@ -35,6 +35,7 @@ data FieldSource
|
||||
-- | Most of these errors should be checked for legitimacy.
|
||||
data Error
|
||||
= UnsupportedOpExpG (IR.OpExpG 'MySQL Expression)
|
||||
| IdentifierNotSupported
|
||||
| FunctionNotSupported
|
||||
| NodesUnsupportedForNow
|
||||
| ConnectionsNotSupported
|
||||
@ -509,6 +510,7 @@ fromSelectAggregate mparentRelationship annSelectG = do
|
||||
selectFrom <-
|
||||
case from of
|
||||
IR.FromTable qualifiedObject -> fromQualifiedTable qualifiedObject
|
||||
IR.FromIdentifier {} -> refute $ pure IdentifierNotSupported
|
||||
IR.FromFunction {} -> refute $ pure FunctionNotSupported
|
||||
_mforeignKeyConditions <- fmap (Where . fromMaybe []) $
|
||||
for mparentRelationship $
|
||||
@ -697,6 +699,7 @@ fromSelectRows annSelectG = do
|
||||
selectFrom <-
|
||||
case from of
|
||||
IR.FromTable qualifiedObject -> fromQualifiedTable qualifiedObject
|
||||
IR.FromIdentifier {} -> refute $ pure IdentifierNotSupported
|
||||
IR.FromFunction {} -> refute $ pure FunctionNotSupported
|
||||
Args
|
||||
{ argsOrderBy,
|
||||
|
@ -15,7 +15,6 @@ import Language.GraphQL.Draft.Syntax qualified as G
|
||||
instance Backend 'MySQL where
|
||||
type SourceConfig 'MySQL = MySQL.SourceConfig
|
||||
type SourceConnConfiguration 'MySQL = MySQL.ConnSourceConfig
|
||||
type Identifier 'MySQL = Void
|
||||
type TableName 'MySQL = MySQL.TableName
|
||||
type FunctionName 'MySQL = MySQL.FunctionName
|
||||
type RawFunctionInfo 'MySQL = Void -- MySQL.FunctionName
|
||||
|
@ -243,8 +243,9 @@ mutateAndFetchCols qt cols (cte, p) strfyNum = do
|
||||
then withCheckPermission $ (first Q.getAltJ . Q.getRow) <$> mutationTx
|
||||
else (Q.getAltJ . runIdentity . Q.getRow) <$> mutationTx
|
||||
where
|
||||
aliasIdentifier = Identifier $ qualifiedObjectToText qt <> "__mutation_result"
|
||||
tabFrom = FromIdentifier aliasIdentifier
|
||||
rawAliasIdentifier = qualifiedObjectToText qt <> "__mutation_result"
|
||||
aliasIdentifier = Identifier rawAliasIdentifier
|
||||
tabFrom = FromIdentifier $ FIIdentifier rawAliasIdentifier
|
||||
tabPerm = TablePerm annBoolExpTrue Nothing
|
||||
selFlds = flip map cols $
|
||||
\ci -> (fromCol @('Postgres pgKind) $ pgiColumn ci, mkAnnColumnFieldAsText ci)
|
||||
|
@ -60,7 +60,6 @@ instance
|
||||
where
|
||||
type SourceConfig ('Postgres pgKind) = PG.PGSourceConfig
|
||||
type SourceConnConfiguration ('Postgres pgKind) = PG.PostgresConnConfiguration
|
||||
type Identifier ('Postgres pgKind) = PG.Identifier
|
||||
type TableName ('Postgres pgKind) = PG.QualifiedTable
|
||||
type FunctionName ('Postgres pgKind) = PG.QualifiedFunction
|
||||
type FunctionArgType ('Postgres pgKind) = PG.QualifiedPGType
|
||||
|
@ -14,7 +14,7 @@ import Hasura.Backends.Postgres.SQL.Types hiding (TableName)
|
||||
import Hasura.Backends.Postgres.Types.BoolExp
|
||||
import Hasura.Base.Error
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types hiding (Identifier)
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.SQL.Types
|
||||
|
||||
-- | Context to parse a RHS value in a boolean expression
|
||||
|
@ -12,6 +12,7 @@ module Hasura.Backends.Postgres.Translate.Returning
|
||||
)
|
||||
where
|
||||
|
||||
import Data.Coerce
|
||||
import Hasura.Backends.Postgres.SQL.DML qualified as S
|
||||
import Hasura.Backends.Postgres.SQL.Types
|
||||
import Hasura.Backends.Postgres.Translate.Select
|
||||
@ -20,7 +21,7 @@ import Hasura.Prelude
|
||||
import Hasura.RQL.DML.Internal
|
||||
import Hasura.RQL.IR.Returning
|
||||
import Hasura.RQL.IR.Select
|
||||
import Hasura.RQL.Types hiding (Identifier)
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.Session
|
||||
|
||||
-- | The postgres common table expression (CTE) for mutation queries.
|
||||
@ -92,12 +93,16 @@ mkMutFldExp cteAlias preCalAffRows strfyNum = \case
|
||||
in maybe countExp (S.SEUnsafe . tshow) preCalAffRows
|
||||
MExp t -> S.SELit t
|
||||
MRet selFlds ->
|
||||
let tabFrom = FromIdentifier cteAlias
|
||||
let tabFrom = FromIdentifier $ toFIIdentifier cteAlias
|
||||
tabPerm = TablePerm annBoolExpTrue Nothing
|
||||
in S.SESelect $
|
||||
mkSQLSelect JASMultipleRows $
|
||||
AnnSelectG selFlds tabFrom tabPerm noSelectArgs strfyNum
|
||||
|
||||
toFIIdentifier :: Identifier -> FIIdentifier
|
||||
toFIIdentifier = coerce . getIdenTxt
|
||||
{-# INLINE toFIIdentifier #-}
|
||||
|
||||
{- Note [Mutation output expression]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
An example output expression for INSERT mutation:
|
||||
@ -167,7 +172,7 @@ mkMutationOutputExp qt allCols preCalAffRows cte mutOutput strfyNum =
|
||||
]
|
||||
in S.SEFnApp "json_build_object" jsonBuildObjArgs Nothing
|
||||
MOutSinglerowObject annFlds ->
|
||||
let tabFrom = FromIdentifier allColumnsAlias
|
||||
let tabFrom = FromIdentifier $ toFIIdentifier allColumnsAlias
|
||||
tabPerm = TablePerm annBoolExpTrue Nothing
|
||||
in S.SESelect $
|
||||
mkSQLSelect JASSingleObject $
|
||||
|
@ -59,7 +59,7 @@ import Hasura.Prelude
|
||||
import Hasura.RQL.DML.Internal
|
||||
import Hasura.RQL.IR.OrderBy
|
||||
import Hasura.RQL.IR.Select
|
||||
import Hasura.RQL.Types hiding (Identifier)
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.SQL.Types
|
||||
|
||||
-- | Translates IR to Postgres queries for simple SELECTs (select queries that
|
||||
@ -114,7 +114,7 @@ asSingleRowJsonResp query args =
|
||||
encJFromBS . runIdentity . Q.getRow
|
||||
<$> Q.rawQE dmlTxErrorHandler query args True
|
||||
|
||||
-- | Converts a function name to an identifier.
|
||||
-- | Converts a function name to an 'Identifier'.
|
||||
--
|
||||
-- If the schema name is public, it will just use its name, otherwise it will
|
||||
-- prefix it by the schema name.
|
||||
@ -124,7 +124,7 @@ functionToIdentifier = Identifier . qualifiedObjectToText
|
||||
selectFromToFromItem :: Identifier -> SelectFrom ('Postgres pgKind) -> S.FromItem
|
||||
selectFromToFromItem pfx = \case
|
||||
FromTable tn -> S.FISimple tn Nothing
|
||||
FromIdentifier i -> S.FIIdentifier i
|
||||
FromIdentifier i -> S.FIIdentifier $ toIdentifier i
|
||||
FromFunction qf args defListM ->
|
||||
S.FIFunc $
|
||||
S.FunctionExp qf (fromTableRowArgs pfx args) $
|
||||
@ -140,7 +140,7 @@ selectFromToFromItem pfx = \case
|
||||
selectFromToQual :: SelectFrom ('Postgres pgKind) -> S.Qual
|
||||
selectFromToQual = \case
|
||||
FromTable table -> S.QualTable table
|
||||
FromIdentifier i -> S.QualifiedIdentifier i Nothing
|
||||
FromIdentifier i -> S.QualifiedIdentifier (toIdentifier i) Nothing
|
||||
FromFunction qf _ _ -> S.QualifiedIdentifier (functionToIdentifier qf) Nothing
|
||||
|
||||
aggregateFieldToExp :: AggregateFields ('Postgres pgKind) -> Bool -> S.SQLExp
|
||||
@ -305,15 +305,16 @@ mkArrayRelationAlias parentFieldName similarFieldsMap fieldName =
|
||||
HM.lookupDefault [fieldName] fieldName similarFieldsMap
|
||||
|
||||
fromTableRowArgs ::
|
||||
Identifier -> FunctionArgsExpTableRow ('Postgres pgKind) S.SQLExp -> S.FunctionArgs
|
||||
fromTableRowArgs pfx = toFunctionArgs . fmap toSQLExp
|
||||
Identifier -> FunctionArgsExpTableRow S.SQLExp -> S.FunctionArgs
|
||||
fromTableRowArgs prefix = toFunctionArgs . fmap toSQLExp
|
||||
where
|
||||
toFunctionArgs (FunctionArgsExp positional named) =
|
||||
S.FunctionArgs positional named
|
||||
toSQLExp (AETableRow Nothing) = S.SERowIdentifier $ mkBaseTableAlias pfx
|
||||
toSQLExp (AETableRow (Just acc)) = S.mkQIdenExp (mkBaseTableAlias pfx) acc
|
||||
toSQLExp (AESession s) = s
|
||||
toSQLExp (AEInput s) = s
|
||||
toSQLExp =
|
||||
onArgumentExp
|
||||
(S.SERowIdentifier alias)
|
||||
(S.mkQIdenExp alias . Identifier)
|
||||
alias = mkBaseTableAlias prefix
|
||||
|
||||
-- uses row_to_json to build a json object
|
||||
withRowToJSON ::
|
||||
|
@ -291,10 +291,9 @@ resolveAsyncActionQuery userInfo annAction =
|
||||
asyncFields <&> second \case
|
||||
AsyncTypename t -> RS.AFExpression t
|
||||
AsyncOutput annFields ->
|
||||
let inputTableArgument = RS.AETableRow $ Just $ Identifier "response_payload"
|
||||
in RS.AFComputedField () (ComputedFieldName $$(nonEmptyText "__action_computed_field")) $
|
||||
RS.CFSTable jsonAggSelect $
|
||||
processOutputSelectionSet inputTableArgument outputType definitionList annFields stringifyNumerics
|
||||
RS.AFComputedField () (ComputedFieldName $$(nonEmptyText "__action_computed_field")) $
|
||||
RS.CFSTable jsonAggSelect $
|
||||
processOutputSelectionSet RS.AEActionResponsePayload outputType definitionList annFields stringifyNumerics
|
||||
AsyncId -> mkAnnFldFromPGCol idColumn
|
||||
AsyncCreatedAt -> mkAnnFldFromPGCol createdAtColumn
|
||||
AsyncErrors -> mkAnnFldFromPGCol errorsColumn
|
||||
@ -316,7 +315,7 @@ resolveAsyncActionQuery userInfo annAction =
|
||||
AnnActionAsyncQuery _ actionId outputType asyncFields definitionList stringifyNumerics _ actionSource = annAction
|
||||
|
||||
idColumn = (unsafePGCol "id", PGUUID)
|
||||
responsePayloadColumn = (unsafePGCol "response_payload", PGJSONB)
|
||||
responsePayloadColumn = (unsafePGCol RS.actionResponsePayloadColumn, PGJSONB)
|
||||
createdAtColumn = (unsafePGCol "created_at", PGTimeStampTZ)
|
||||
errorsColumn = (unsafePGCol "errors", PGJSONB)
|
||||
sessionVarsColumn = (unsafePGCol "session_variables", PGJSONB)
|
||||
@ -608,7 +607,7 @@ callWebhook
|
||||
"expecting not null value for field " <>> fieldName
|
||||
|
||||
processOutputSelectionSet ::
|
||||
RS.ArgumentExp ('Postgres 'Vanilla) v ->
|
||||
RS.ArgumentExp v ->
|
||||
GraphQLType ->
|
||||
[(PGCol, PGScalarType)] ->
|
||||
RS.AnnFieldsG ('Postgres 'Vanilla) r v ->
|
||||
|
@ -1301,16 +1301,14 @@ computedFieldPG sourceName ComputedFieldInfo {..} parentTable selectPermissions
|
||||
|
||||
computedFieldFunctionArgs ::
|
||||
ComputedFieldFunction ('Postgres pgKind) ->
|
||||
m (InputFieldsParser n (IR.FunctionArgsExpTableRow ('Postgres pgKind) (UnpreparedValue ('Postgres pgKind))))
|
||||
m (InputFieldsParser n (IR.FunctionArgsExpTableRow (UnpreparedValue ('Postgres pgKind))))
|
||||
computedFieldFunctionArgs ComputedFieldFunction {..} =
|
||||
functionArgs (FTAComputedField _cfiName sourceName parentTable) (IAUserProvided <$> _cffInputArgs) <&> fmap addTableAndSessionArgument
|
||||
where
|
||||
tableRowArgument = IR.AETableRow Nothing
|
||||
|
||||
addTableAndSessionArgument args@(IR.FunctionArgsExp positional named) =
|
||||
let withTable = case _cffTableArgument of
|
||||
FTAFirst -> IR.FunctionArgsExp (tableRowArgument : positional) named
|
||||
FTANamed argName index -> IR.insertFunctionArg argName index tableRowArgument args
|
||||
FTAFirst -> IR.FunctionArgsExp (IR.AETableRow : positional) named
|
||||
FTANamed argName index -> IR.insertFunctionArg argName index IR.AETableRow args
|
||||
sessionArgVal = IR.AESession UVSession
|
||||
in case _cffSessionArgument of
|
||||
Nothing -> withTable
|
||||
@ -1416,7 +1414,7 @@ customSQLFunctionArgs ::
|
||||
FunctionInfo b ->
|
||||
G.Name ->
|
||||
G.Name ->
|
||||
m (InputFieldsParser n (IR.FunctionArgsExpTableRow b (UnpreparedValue b)))
|
||||
m (InputFieldsParser n (IR.FunctionArgsExpTableRow (UnpreparedValue b)))
|
||||
customSQLFunctionArgs FunctionInfo {..} functionName functionArgsName =
|
||||
functionArgs
|
||||
( FTACustomFunction $
|
||||
@ -1447,7 +1445,7 @@ functionArgs ::
|
||||
) =>
|
||||
FunctionTrackedAs b ->
|
||||
Seq.Seq (FunctionInputArgument b) ->
|
||||
m (InputFieldsParser n (IR.FunctionArgsExpTableRow b (UnpreparedValue b)))
|
||||
m (InputFieldsParser n (IR.FunctionArgsExpTableRow (UnpreparedValue b)))
|
||||
functionArgs functionTrackedAs (toList -> inputArgs) = do
|
||||
-- First, we iterate through the original sql arguments in order, to find the
|
||||
-- corresponding graphql names. At the same time, we create the input field
|
||||
@ -1514,7 +1512,7 @@ functionArgs functionTrackedAs (toList -> inputArgs) = do
|
||||
|
||||
pure $ P.field fieldName (Just fieldDesc) objectParser
|
||||
where
|
||||
sessionPlaceholder :: IR.ArgumentExp b (UnpreparedValue b)
|
||||
sessionPlaceholder :: IR.ArgumentExp (UnpreparedValue b)
|
||||
sessionPlaceholder = IR.AEInput P.UVSession
|
||||
|
||||
splitArguments ::
|
||||
@ -1522,9 +1520,9 @@ functionArgs functionTrackedAs (toList -> inputArgs) = do
|
||||
FunctionInputArgument b ->
|
||||
( Int,
|
||||
( [Text], -- graphql names, in order
|
||||
[(Text, IR.ArgumentExp b (UnpreparedValue b))], -- session argument
|
||||
[m (InputFieldsParser n (Maybe (Text, IR.ArgumentExp b (UnpreparedValue b))))], -- optional argument
|
||||
[m (InputFieldsParser n (Maybe (Text, IR.ArgumentExp b (UnpreparedValue b))))] -- mandatory argument
|
||||
[(Text, IR.ArgumentExp (UnpreparedValue b))], -- session argument
|
||||
[m (InputFieldsParser n (Maybe (Text, IR.ArgumentExp (UnpreparedValue b))))], -- optional argument
|
||||
[m (InputFieldsParser n (Maybe (Text, IR.ArgumentExp (UnpreparedValue b))))] -- mandatory argument
|
||||
)
|
||||
)
|
||||
splitArguments positionalIndex (IASessionVariables name) =
|
||||
@ -1538,7 +1536,7 @@ functionArgs functionTrackedAs (toList -> inputArgs) = do
|
||||
then (newIndex, ([argName], [], [parseArgument arg argName], []))
|
||||
else (newIndex, ([argName], [], [], [parseArgument arg argName]))
|
||||
|
||||
parseArgument :: FunctionArg b -> Text -> m (InputFieldsParser n (Maybe (Text, IR.ArgumentExp b (UnpreparedValue b))))
|
||||
parseArgument :: FunctionArg b -> Text -> m (InputFieldsParser n (Maybe (Text, IR.ArgumentExp (UnpreparedValue b))))
|
||||
parseArgument arg name = do
|
||||
typedParser <- columnParser (ColumnScalar $ functionArgScalarType @b $ faType arg) (G.Nullability True)
|
||||
fieldName <- textToName name
|
||||
@ -1557,9 +1555,9 @@ functionArgs functionTrackedAs (toList -> inputArgs) = do
|
||||
pure $ argParser `mapField` ((name,) . IR.AEInput . mkParameter)
|
||||
|
||||
namedArgument ::
|
||||
HashMap Text (IR.ArgumentExp b (UnpreparedValue b)) ->
|
||||
HashMap Text (IR.ArgumentExp (UnpreparedValue b)) ->
|
||||
(Text, FunctionInputArgument b) ->
|
||||
n (Maybe (Text, IR.ArgumentExp b (UnpreparedValue b)))
|
||||
n (Maybe (Text, IR.ArgumentExp (UnpreparedValue b)))
|
||||
namedArgument dictionary (name, inputArgument) = case inputArgument of
|
||||
IASessionVariables _ -> pure $ Just (name, sessionPlaceholder)
|
||||
IAUserProvided arg -> case Map.lookup name dictionary of
|
||||
|
@ -1,3 +1,4 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
|
||||
-- | This modules defines the tree of Select types: how we represent a query internally, from its top
|
||||
@ -70,6 +71,7 @@ module Hasura.RQL.IR.Select
|
||||
FunctionArgExp,
|
||||
FunctionArgsExpG (..),
|
||||
FunctionArgsExpTableRow,
|
||||
FIIdentifier (..),
|
||||
ObjectRelationSelect,
|
||||
ObjectRelationSelectG,
|
||||
PageInfoField (..),
|
||||
@ -88,6 +90,7 @@ module Hasura.RQL.IR.Select
|
||||
TableAggregateFieldsG,
|
||||
TablePerm,
|
||||
TablePermG (..),
|
||||
actionResponsePayloadColumn,
|
||||
asnArgs,
|
||||
asnFields,
|
||||
asnFrom,
|
||||
@ -100,6 +103,7 @@ module Hasura.RQL.IR.Select
|
||||
mkAnnColumnFieldAsText,
|
||||
noSelectArgs,
|
||||
noTablePermissions,
|
||||
onArgumentExp,
|
||||
saDistinct,
|
||||
saLimit,
|
||||
saOffset,
|
||||
@ -125,6 +129,7 @@ import Data.Int (Int64)
|
||||
import Data.Kind (Type)
|
||||
import Data.List.NonEmpty qualified as NE
|
||||
import Data.Sequence qualified as Seq
|
||||
import Hasura.Backends.Postgres.SQL.Types qualified as PG
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.IR.BoolExp
|
||||
import Hasura.RQL.IR.OrderBy
|
||||
@ -156,9 +161,9 @@ data AnnSelectG (b :: BackendType) (r :: Type) (f :: Type -> Type) (v :: Type) =
|
||||
_asnArgs :: !(SelectArgsG b v),
|
||||
_asnStrfyNum :: !Bool
|
||||
}
|
||||
deriving (Functor, Foldable, Traversable)
|
||||
deriving stock (Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Eq (BooleanOperators b v),
|
||||
Eq v,
|
||||
@ -166,7 +171,7 @@ deriving instance
|
||||
) =>
|
||||
Eq (AnnSelectG b r f v)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Show (BooleanOperators b v),
|
||||
Show v,
|
||||
@ -191,9 +196,9 @@ data ConnectionSelect (b :: BackendType) (r :: Type) v = ConnectionSelect
|
||||
_csSlice :: !(Maybe ConnectionSlice),
|
||||
_csSelect :: !(AnnSelectG b r (ConnectionField b r) v)
|
||||
}
|
||||
deriving (Functor, Foldable, Traversable)
|
||||
deriving stock (Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Eq (BooleanOperators b v),
|
||||
Eq v,
|
||||
@ -201,7 +206,7 @@ deriving instance
|
||||
) =>
|
||||
Eq (ConnectionSelect b r v)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Show (BooleanOperators b v),
|
||||
Show v,
|
||||
@ -214,7 +219,7 @@ data ConnectionSplit (b :: BackendType) v = ConnectionSplit
|
||||
_csValue :: !v,
|
||||
_csOrderBy :: !(OrderByItemG b (AnnotatedOrderByElement b v))
|
||||
}
|
||||
deriving (Functor, Generic, Foldable, Traversable)
|
||||
deriving stock (Functor, Generic, Foldable, Traversable)
|
||||
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
@ -241,32 +246,42 @@ instance
|
||||
data ConnectionSlice
|
||||
= SliceFirst !Int
|
||||
| SliceLast !Int
|
||||
deriving (Show, Eq, Generic)
|
||||
|
||||
instance Hashable ConnectionSlice
|
||||
deriving stock (Show, Eq, Generic)
|
||||
deriving anyclass (Hashable)
|
||||
|
||||
data ConnectionSplitKind
|
||||
= CSKBefore
|
||||
| CSKAfter
|
||||
deriving (Show, Eq, Generic)
|
||||
|
||||
instance Hashable ConnectionSplitKind
|
||||
deriving stock (Show, Eq, Generic)
|
||||
deriving anyclass (Hashable)
|
||||
|
||||
-- From
|
||||
|
||||
-- | Identifier used exclusively as the argument to 'FromIdentifier'
|
||||
newtype FIIdentifier = FIIdentifier
|
||||
{ unFIIdentifier :: Text
|
||||
}
|
||||
deriving stock (Generic)
|
||||
deriving newtype (Eq, Show)
|
||||
deriving anyclass (Hashable)
|
||||
|
||||
instance PG.IsIdentifier FIIdentifier where
|
||||
toIdentifier = coerce
|
||||
{-# INLINE toIdentifier #-}
|
||||
|
||||
data SelectFromG (b :: BackendType) v
|
||||
= FromTable !(TableName b)
|
||||
| FromIdentifier !(Identifier b)
|
||||
| FromIdentifier !FIIdentifier
|
||||
| FromFunction
|
||||
!(FunctionName b)
|
||||
!(FunctionArgsExpTableRow b v)
|
||||
!(FunctionArgsExpTableRow v)
|
||||
-- a definition list
|
||||
!(Maybe [(Column b, ScalarType b)])
|
||||
deriving (Functor, Foldable, Traversable, Generic)
|
||||
deriving stock (Functor, Foldable, Traversable, Generic)
|
||||
|
||||
deriving instance (Backend b, Eq v) => Eq (SelectFromG b v)
|
||||
deriving stock instance (Backend b, Eq v) => Eq (SelectFromG b v)
|
||||
|
||||
deriving instance (Backend b, Show v) => Show (SelectFromG b v)
|
||||
deriving stock instance (Backend b, Show v) => Show (SelectFromG b v)
|
||||
|
||||
instance (Backend b, Hashable v) => Hashable (SelectFromG b v)
|
||||
|
||||
@ -281,9 +296,9 @@ data SelectArgsG (b :: BackendType) v = SelectArgs
|
||||
_saOffset :: !(Maybe Int64),
|
||||
_saDistinct :: !(Maybe (NE.NonEmpty (Column b)))
|
||||
}
|
||||
deriving (Generic, Functor, Foldable, Traversable)
|
||||
deriving stock (Generic, Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Eq (BooleanOperators b v),
|
||||
Eq v
|
||||
@ -297,7 +312,7 @@ instance
|
||||
) =>
|
||||
Hashable (SelectArgsG b v)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Show (BooleanOperators b v),
|
||||
Show v
|
||||
@ -321,11 +336,11 @@ data ComputedFieldOrderByElement (b :: BackendType) v
|
||||
-- ^ Permission filter of the retuning table
|
||||
!(AnnotatedAggregateOrderBy b)
|
||||
-- ^ Sort by aggregation fields of table rows returned by computed field
|
||||
deriving (Generic, Functor, Foldable, Traversable)
|
||||
deriving stock (Generic, Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance (Backend b, Eq v, Eq (BooleanOperators b v)) => Eq (ComputedFieldOrderByElement b v)
|
||||
deriving stock instance (Backend b, Eq v, Eq (BooleanOperators b v)) => Eq (ComputedFieldOrderByElement b v)
|
||||
|
||||
deriving instance (Backend b, Show v, Show (BooleanOperators b v)) => Show (ComputedFieldOrderByElement b v)
|
||||
deriving stock instance (Backend b, Show v, Show (BooleanOperators b v)) => Show (ComputedFieldOrderByElement b v)
|
||||
|
||||
instance (Backend b, Hashable v, Hashable (BooleanOperators b v)) => Hashable (ComputedFieldOrderByElement b v)
|
||||
|
||||
@ -333,14 +348,14 @@ data ComputedFieldOrderBy (b :: BackendType) v = ComputedFieldOrderBy
|
||||
{ _cfobXField :: !(XComputedField b),
|
||||
_cfobName :: !ComputedFieldName,
|
||||
_cfobFunction :: !(FunctionName b),
|
||||
_cfobFunctionArgsExp :: !(FunctionArgsExpTableRow b v),
|
||||
_cfobFunctionArgsExp :: !(FunctionArgsExpTableRow v),
|
||||
_cfobOrderByElement :: !(ComputedFieldOrderByElement b v)
|
||||
}
|
||||
deriving (Generic, Functor, Foldable, Traversable)
|
||||
deriving stock (Generic, Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance (Backend b, Eq v, Eq (BooleanOperators b v)) => Eq (ComputedFieldOrderBy b v)
|
||||
deriving stock instance (Backend b, Eq v, Eq (BooleanOperators b v)) => Eq (ComputedFieldOrderBy b v)
|
||||
|
||||
deriving instance (Backend b, Show v, Show (BooleanOperators b v)) => Show (ComputedFieldOrderBy b v)
|
||||
deriving stock instance (Backend b, Show v, Show (BooleanOperators b v)) => Show (ComputedFieldOrderBy b v)
|
||||
|
||||
instance (Backend b, Hashable v, Hashable (BooleanOperators b v)) => Hashable (ComputedFieldOrderBy b v)
|
||||
|
||||
@ -357,22 +372,22 @@ data AnnotatedOrderByElement (b :: BackendType) v
|
||||
-- ^ Permission filter of the remote table to which the relationship is defined
|
||||
!(AnnotatedAggregateOrderBy b)
|
||||
| AOCComputedField !(ComputedFieldOrderBy b v)
|
||||
deriving (Generic, Functor, Foldable, Traversable)
|
||||
deriving stock (Generic, Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance (Backend b, Eq v, Eq (BooleanOperators b v)) => Eq (AnnotatedOrderByElement b v)
|
||||
deriving stock instance (Backend b, Eq v, Eq (BooleanOperators b v)) => Eq (AnnotatedOrderByElement b v)
|
||||
|
||||
deriving instance (Backend b, Show v, Show (BooleanOperators b v)) => Show (AnnotatedOrderByElement b v)
|
||||
deriving stock instance (Backend b, Show v, Show (BooleanOperators b v)) => Show (AnnotatedOrderByElement b v)
|
||||
|
||||
instance (Backend b, Hashable v, Hashable (BooleanOperators b v)) => Hashable (AnnotatedOrderByElement b v)
|
||||
|
||||
data AnnotatedAggregateOrderBy (b :: BackendType)
|
||||
= AAOCount
|
||||
| AAOOp !Text !(ColumnInfo b)
|
||||
deriving (Generic)
|
||||
deriving stock (Generic)
|
||||
|
||||
deriving instance (Backend b) => Eq (AnnotatedAggregateOrderBy b)
|
||||
deriving stock instance (Backend b) => Eq (AnnotatedAggregateOrderBy b)
|
||||
|
||||
deriving instance (Backend b) => Show (AnnotatedAggregateOrderBy b)
|
||||
deriving stock instance (Backend b) => Show (AnnotatedAggregateOrderBy b)
|
||||
|
||||
instance (Backend b) => Hashable (AnnotatedAggregateOrderBy b)
|
||||
|
||||
@ -408,9 +423,9 @@ data AnnFieldG (b :: BackendType) (r :: Type) v
|
||||
AFRemote !(RemoteRelationshipSelect b r)
|
||||
| AFNodeId !(XRelay b) !(TableName b) !(PrimaryKeyColumns b)
|
||||
| AFExpression !Text
|
||||
deriving (Functor, Foldable, Traversable)
|
||||
deriving stock (Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Eq (BooleanOperators b v),
|
||||
Eq v,
|
||||
@ -418,7 +433,7 @@ deriving instance
|
||||
) =>
|
||||
Eq (AnnFieldG b r v)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Show (BooleanOperators b v),
|
||||
Show v,
|
||||
@ -451,9 +466,9 @@ data TableAggregateFieldG (b :: BackendType) (r :: Type) v
|
||||
= TAFAgg !(AggregateFields b)
|
||||
| TAFNodes (XNodesAgg b) !(AnnFieldsG b r v)
|
||||
| TAFExp !Text
|
||||
deriving (Functor, Foldable, Traversable)
|
||||
deriving stock (Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Eq (BooleanOperators b v),
|
||||
Eq v,
|
||||
@ -461,7 +476,7 @@ deriving instance
|
||||
) =>
|
||||
Eq (TableAggregateFieldG b r v)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Show (BooleanOperators b v),
|
||||
Show v,
|
||||
@ -474,9 +489,9 @@ data AggregateField (b :: BackendType)
|
||||
| AFOp !(AggregateOp b)
|
||||
| AFExp !Text
|
||||
|
||||
deriving instance (Backend b) => Eq (AggregateField b)
|
||||
deriving stock instance (Backend b) => Eq (AggregateField b)
|
||||
|
||||
deriving instance (Backend b) => Show (AggregateField b)
|
||||
deriving stock instance (Backend b) => Show (AggregateField b)
|
||||
|
||||
data AggregateOp (b :: BackendType) = AggregateOp
|
||||
{ _aoOp :: !Text,
|
||||
@ -507,9 +522,9 @@ data ConnectionField (b :: BackendType) (r :: Type) v
|
||||
= ConnectionTypename !Text
|
||||
| ConnectionPageInfo !PageInfoFields
|
||||
| ConnectionEdges !(EdgeFields b r v)
|
||||
deriving (Functor, Foldable, Traversable)
|
||||
deriving stock (Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Eq (BooleanOperators b v),
|
||||
Eq v,
|
||||
@ -517,7 +532,7 @@ deriving instance
|
||||
) =>
|
||||
Eq (ConnectionField b r v)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Show (BooleanOperators b v),
|
||||
Show v,
|
||||
@ -531,15 +546,15 @@ data PageInfoField
|
||||
| PageInfoHasPreviousPage
|
||||
| PageInfoStartCursor
|
||||
| PageInfoEndCursor
|
||||
deriving (Show, Eq)
|
||||
deriving stock (Show, Eq)
|
||||
|
||||
data EdgeField (b :: BackendType) (r :: Type) v
|
||||
= EdgeTypename !Text
|
||||
| EdgeCursor
|
||||
| EdgeNode !(AnnFieldsG b r v)
|
||||
deriving (Functor, Foldable, Traversable)
|
||||
deriving stock (Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Eq (BooleanOperators b v),
|
||||
Eq v,
|
||||
@ -547,7 +562,7 @@ deriving instance
|
||||
) =>
|
||||
Eq (EdgeField b r v)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Show (BooleanOperators b v),
|
||||
Show v,
|
||||
@ -578,16 +593,16 @@ data AnnColumnField (b :: BackendType) v = AnnColumnField
|
||||
-- when `c` evaluates to `false`.
|
||||
_acfCaseBoolExpression :: !(Maybe (AnnColumnCaseBoolExp b v))
|
||||
}
|
||||
deriving (Functor, Foldable, Traversable)
|
||||
deriving stock (Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Eq (BooleanOperators b v),
|
||||
Eq v
|
||||
) =>
|
||||
Eq (AnnColumnField b v)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Show (BooleanOperators b v),
|
||||
Show v
|
||||
@ -599,23 +614,23 @@ data ColumnOp (b :: BackendType) = ColumnOp
|
||||
_colExp :: SQLExpression b
|
||||
}
|
||||
|
||||
deriving instance Backend b => Show (ColumnOp b)
|
||||
deriving stock instance Backend b => Show (ColumnOp b)
|
||||
|
||||
deriving instance Backend b => Eq (ColumnOp b)
|
||||
deriving stock instance Backend b => Eq (ColumnOp b)
|
||||
|
||||
-- Computed field
|
||||
|
||||
data ComputedFieldScalarSelect (b :: BackendType) v = ComputedFieldScalarSelect
|
||||
{ _cfssFunction :: !(FunctionName b),
|
||||
_cfssArguments :: !(FunctionArgsExpTableRow b v),
|
||||
_cfssArguments :: !(FunctionArgsExpTableRow v),
|
||||
_cfssType :: !(ScalarType b),
|
||||
_cfssColumnOp :: !(Maybe (ColumnOp b))
|
||||
}
|
||||
deriving (Functor, Foldable, Traversable)
|
||||
deriving stock (Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance (Backend b, Show v) => Show (ComputedFieldScalarSelect b v)
|
||||
deriving stock instance (Backend b, Show v) => Show (ComputedFieldScalarSelect b v)
|
||||
|
||||
deriving instance (Backend b, Eq v) => Eq (ComputedFieldScalarSelect b v)
|
||||
deriving stock instance (Backend b, Eq v) => Eq (ComputedFieldScalarSelect b v)
|
||||
|
||||
data ComputedFieldSelect (b :: BackendType) (r :: Type) v
|
||||
= CFSScalar
|
||||
@ -628,9 +643,9 @@ data ComputedFieldSelect (b :: BackendType) (r :: Type) v
|
||||
-- value is `Just c`, the scalar computed field will be outputted when
|
||||
-- `c` evaluates to `true` and `null` when `c` evaluates to `false`
|
||||
| CFSTable !JsonAggSelect !(AnnSimpleSelectG b r v)
|
||||
deriving (Functor, Foldable, Traversable)
|
||||
deriving stock (Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Eq (BooleanOperators b v),
|
||||
Eq v,
|
||||
@ -638,7 +653,7 @@ deriving instance
|
||||
) =>
|
||||
Eq (ComputedFieldSelect b r v)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Show (BooleanOperators b v),
|
||||
Show v,
|
||||
@ -653,11 +668,11 @@ data AnnRelationSelectG (b :: BackendType) a = AnnRelationSelectG
|
||||
aarColumnMapping :: !(HashMap (Column b) (Column b)), -- Column of left table to join with
|
||||
aarAnnSelect :: !a -- Current table. Almost ~ to SQL Select
|
||||
}
|
||||
deriving (Functor, Foldable, Traversable)
|
||||
deriving stock (Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance (Backend b, Eq v) => Eq (AnnRelationSelectG b v)
|
||||
deriving stock instance (Backend b, Eq v) => Eq (AnnRelationSelectG b v)
|
||||
|
||||
deriving instance (Backend b, Show v) => Show (AnnRelationSelectG b v)
|
||||
deriving stock instance (Backend b, Show v) => Show (AnnRelationSelectG b v)
|
||||
|
||||
type ArrayRelationSelectG b r v = AnnRelationSelectG b (AnnSimpleSelectG b r v)
|
||||
|
||||
@ -672,9 +687,9 @@ data AnnObjectSelectG (b :: BackendType) (r :: Type) v = AnnObjectSelectG
|
||||
_aosTableFrom :: !(TableName b),
|
||||
_aosTableFilter :: !(AnnBoolExp b v)
|
||||
}
|
||||
deriving (Functor, Foldable, Traversable)
|
||||
deriving stock (Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Eq (BooleanOperators b v),
|
||||
Eq v,
|
||||
@ -682,7 +697,7 @@ deriving instance
|
||||
) =>
|
||||
Eq (AnnObjectSelectG b r v)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Show (BooleanOperators b v),
|
||||
Show v,
|
||||
@ -700,9 +715,9 @@ data ArraySelectG (b :: BackendType) (r :: Type) v
|
||||
= ASSimple !(ArrayRelationSelectG b r v)
|
||||
| ASAggregate !(ArrayAggregateSelectG b r v)
|
||||
| ASConnection !(ArrayConnectionSelect b r v)
|
||||
deriving (Functor, Foldable, Traversable)
|
||||
deriving stock (Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Eq (BooleanOperators b v),
|
||||
Eq v,
|
||||
@ -710,7 +725,7 @@ deriving instance
|
||||
) =>
|
||||
Eq (ArraySelectG b r v)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Show (BooleanOperators b v),
|
||||
Show v,
|
||||
@ -732,7 +747,7 @@ data
|
||||
| SourceRelationshipArray !(AnnSimpleSelectG b r (vf b))
|
||||
| SourceRelationshipArrayAggregate !(AnnAggregateSelectG b r (vf b))
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Eq (BooleanOperators b (v b)),
|
||||
Eq (v b),
|
||||
@ -740,7 +755,7 @@ deriving instance
|
||||
) =>
|
||||
Eq (SourceRelationshipSelection b r v)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Show (BooleanOperators b (v b)),
|
||||
Show (v b),
|
||||
@ -775,16 +790,16 @@ data TablePermG (b :: BackendType) v = TablePerm
|
||||
{ _tpFilter :: !(AnnBoolExp b v),
|
||||
_tpLimit :: !(Maybe Int)
|
||||
}
|
||||
deriving (Generic, Functor, Foldable, Traversable)
|
||||
deriving stock (Generic, Functor, Foldable, Traversable)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Eq (BooleanOperators b v),
|
||||
Eq v
|
||||
) =>
|
||||
Eq (TablePermG b v)
|
||||
|
||||
deriving instance
|
||||
deriving stock instance
|
||||
( Backend b,
|
||||
Show (BooleanOperators b v),
|
||||
Show v
|
||||
@ -806,29 +821,47 @@ noTablePermissions = TablePerm annBoolExpTrue Nothing
|
||||
|
||||
-- Function arguments
|
||||
|
||||
data ArgumentExp (b :: BackendType) a
|
||||
= -- | table row accessor
|
||||
AETableRow !(Maybe (Identifier b))
|
||||
data ArgumentExp a
|
||||
= -- | Table row accessor
|
||||
AETableRow
|
||||
| -- | Hardcoded reference to @hdb_catalog.hdb_action_log.response_payload@
|
||||
AEActionResponsePayload
|
||||
| -- | JSON/JSONB hasura session variable object
|
||||
AESession !a
|
||||
| AEInput !a
|
||||
deriving (Functor, Foldable, Traversable, Generic)
|
||||
deriving stock (Eq, Show, Functor, Foldable, Traversable, Generic)
|
||||
deriving anyclass (Hashable)
|
||||
|
||||
deriving instance (Backend b, Show a) => Show (ArgumentExp b a)
|
||||
-- | Eliminate 'ArgumentExp'
|
||||
--
|
||||
-- Used to ensure that the right column is used for 'AEActionResponsePayload'.
|
||||
onArgumentExp ::
|
||||
-- | Value to return for 'AETableRow'
|
||||
a ->
|
||||
-- | Create value to return for 'AEResponsePayload' given column text
|
||||
(Text -> a) ->
|
||||
-- | 'ArgumentExp' to eliminate
|
||||
ArgumentExp a ->
|
||||
a
|
||||
onArgumentExp tableRow fromColumn = \case
|
||||
AETableRow -> tableRow
|
||||
AEActionResponsePayload -> fromColumn actionResponsePayloadColumn
|
||||
AESession a -> a
|
||||
AEInput a -> a
|
||||
|
||||
deriving instance (Backend b, Eq a) => Eq (ArgumentExp b a)
|
||||
|
||||
instance (Backend b, Hashable v) => Hashable (ArgumentExp b v)
|
||||
-- | Hardcoded @hdb_catalog.hdb_action_log.response_payload@ column name
|
||||
actionResponsePayloadColumn :: Text
|
||||
actionResponsePayloadColumn = "response_payload"
|
||||
{-# INLINE actionResponsePayloadColumn #-}
|
||||
|
||||
data FunctionArgsExpG a = FunctionArgsExp
|
||||
{ _faePositional :: ![a],
|
||||
_faeNamed :: !(HM.HashMap Text a)
|
||||
}
|
||||
deriving (Show, Eq, Functor, Foldable, Traversable, Generic)
|
||||
deriving stock (Show, Eq, Functor, Foldable, Traversable, Generic)
|
||||
deriving anyclass (Hashable)
|
||||
|
||||
instance (Hashable a) => Hashable (FunctionArgsExpG a)
|
||||
|
||||
type FunctionArgsExpTableRow b v = FunctionArgsExpG (ArgumentExp b v)
|
||||
type FunctionArgsExpTableRow v = FunctionArgsExpG (ArgumentExp v)
|
||||
|
||||
type FunctionArgExp b = FunctionArgsExpG (SQLExpression b)
|
||||
|
||||
@ -839,11 +872,11 @@ functionArgsWithTableRowAndSession ::
|
||||
v ->
|
||||
FunctionTableArgument ->
|
||||
Maybe FunctionSessionArgument ->
|
||||
[ArgumentExp b v]
|
||||
functionArgsWithTableRowAndSession _ _ Nothing = [AETableRow Nothing] -- No session argument
|
||||
functionArgsWithTableRowAndSession sess (FTAFirst) _ = [AETableRow Nothing, AESession sess]
|
||||
functionArgsWithTableRowAndSession sess (FTANamed _ 0) _ = [AETableRow Nothing, AESession sess] -- Index is 0 implies table argument is first
|
||||
functionArgsWithTableRowAndSession sess _ _ = [AESession sess, AETableRow Nothing]
|
||||
[ArgumentExp v]
|
||||
functionArgsWithTableRowAndSession _ _ Nothing = [AETableRow] -- No session argument
|
||||
functionArgsWithTableRowAndSession sess (FTAFirst) _ = [AETableRow, AESession sess]
|
||||
functionArgsWithTableRowAndSession sess (FTANamed _ 0) _ = [AETableRow, AESession sess] -- Index is 0 implies table argument is first
|
||||
functionArgsWithTableRowAndSession sess _ _ = [AESession sess, AETableRow]
|
||||
|
||||
-- | If argument positional index is less than or equal to length of
|
||||
-- 'positional' arguments then insert the value in 'positional' arguments else
|
||||
|
@ -46,8 +46,7 @@ type XDisable = Void
|
||||
-- type application or a 'Proxy' parameter to disambiguate between
|
||||
-- different backends at the call site.
|
||||
class
|
||||
( Representable (Identifier b),
|
||||
Representable (TableName b),
|
||||
( Representable (TableName b),
|
||||
Representable (FunctionName b),
|
||||
Representable (FunctionArgType b),
|
||||
Representable (ConstraintName b),
|
||||
@ -118,7 +117,6 @@ class
|
||||
-- types
|
||||
type SourceConfig b :: Type
|
||||
type SourceConnConfiguration b :: Type
|
||||
type Identifier b :: Type
|
||||
type TableName b :: Type
|
||||
type RawFunctionInfo b :: Type
|
||||
type FunctionName b :: Type
|
||||
|
@ -39,7 +39,6 @@ genAnnSelectG ::
|
||||
Hashable (ScalarType b) =>
|
||||
Hashable (Column b) =>
|
||||
m (TableName b) ->
|
||||
m (Identifier b) ->
|
||||
m (FunctionName b) ->
|
||||
m (Column b) ->
|
||||
m (ScalarType b) ->
|
||||
@ -77,7 +76,6 @@ genAnnSelectG ::
|
||||
m (AnnSelectG b r f a)
|
||||
genAnnSelectG
|
||||
genTableName
|
||||
genIdentifier
|
||||
genFunctionName
|
||||
genColumn
|
||||
genScalarType
|
||||
@ -122,11 +120,11 @@ genAnnSelectG
|
||||
genFrom =
|
||||
genSelectFromG
|
||||
genTableName
|
||||
genIdentifier
|
||||
genFunctionName
|
||||
genColumn
|
||||
genScalarType
|
||||
genA
|
||||
nameRange
|
||||
functionDefinitionListRange
|
||||
funArgPositionalRange
|
||||
funArgsNameRange
|
||||
@ -161,7 +159,6 @@ genAnnSelectG
|
||||
genTableName
|
||||
genScalarType
|
||||
genFunctionName
|
||||
genIdentifier
|
||||
genXComputedField
|
||||
genBooleanOperators
|
||||
genBasicOrderType
|
||||
@ -205,7 +202,6 @@ genSelectFromG ::
|
||||
forall b a m.
|
||||
MonadGen m =>
|
||||
m (TableName b) ->
|
||||
m (Identifier b) ->
|
||||
m (FunctionName b) ->
|
||||
m (Column b) ->
|
||||
m (ScalarType b) ->
|
||||
@ -214,14 +210,15 @@ genSelectFromG ::
|
||||
Range Int ->
|
||||
Range Int ->
|
||||
Range Int ->
|
||||
Range Int ->
|
||||
m (SelectFromG b a)
|
||||
genSelectFromG
|
||||
genTableName
|
||||
genIdentifier
|
||||
genFunctionName
|
||||
genColumn
|
||||
genScalarType
|
||||
genA
|
||||
nameRange
|
||||
funDefinitionListRange
|
||||
funArgPositionalRange
|
||||
funArgsNameRange
|
||||
@ -229,12 +226,12 @@ genSelectFromG
|
||||
choice [fromTable, fromIdentifier, fromFunction]
|
||||
where
|
||||
fromTable = FromTable <$> genTableName
|
||||
fromIdentifier = FromIdentifier <$> genIdentifier
|
||||
fromIdentifier = FromIdentifier <$> genIdentifier nameRange
|
||||
fromFunction =
|
||||
FromFunction
|
||||
<$> genFunctionName
|
||||
<*> genFunctionArgsExpG
|
||||
(genArgumentExp genIdentifier genA)
|
||||
(genArgumentExp genA)
|
||||
funArgPositionalRange
|
||||
funArgsNameRange
|
||||
funArgsNamedRange
|
||||
@ -348,7 +345,6 @@ genSelectArgsG ::
|
||||
m (TableName b) ->
|
||||
m (ScalarType b) ->
|
||||
m (FunctionName b) ->
|
||||
m (Identifier b) ->
|
||||
m (XComputedField b) ->
|
||||
m (BooleanOperators b a) ->
|
||||
m (BasicOrderType b) ->
|
||||
@ -382,7 +378,6 @@ genSelectArgsG
|
||||
genTableName
|
||||
genScalarType
|
||||
genFunctionName
|
||||
genIdentifier
|
||||
genXComputedField
|
||||
genBooleanOperators
|
||||
genBasicOrderType
|
||||
@ -459,7 +454,6 @@ genSelectArgsG
|
||||
genTableName
|
||||
genScalarType
|
||||
genFunctionName
|
||||
genIdentifier
|
||||
genXComputedField
|
||||
genBooleanOperators
|
||||
genA
|
||||
@ -505,10 +499,14 @@ genFunctionArgsExpG genA positionalRange nameRange namedRange =
|
||||
<$> list positionalRange genA
|
||||
<*> genHashMap (genArbitraryUnicodeText nameRange) genA namedRange
|
||||
|
||||
genArgumentExp :: MonadGen m => m (Identifier b) -> m a -> m (ArgumentExp b a)
|
||||
genArgumentExp genIdentifier genA = choice [tableRow, session, input]
|
||||
genArgumentExp :: MonadGen m => m a -> m (ArgumentExp a)
|
||||
genArgumentExp genA = choice [tableRow, session, input]
|
||||
where
|
||||
tableRow = AETableRow <$> maybe genIdentifier
|
||||
-- Don't actually generate this except manually, as it presumes
|
||||
-- that the root table has a specific column.
|
||||
--
|
||||
-- responsePayload = pure AEActionResponsePayload
|
||||
tableRow = pure AETableRow
|
||||
session = AESession <$> genA
|
||||
input = AEInput <$> genA
|
||||
|
||||
@ -702,6 +700,9 @@ genRelType = element [ObjRel, ArrRel]
|
||||
genInsertOrder :: MonadGen m => m InsertOrder
|
||||
genInsertOrder = element [BeforeParent, AfterParent]
|
||||
|
||||
genIdentifier :: MonadGen m => Range Int -> m FIIdentifier
|
||||
genIdentifier range = FIIdentifier <$> genArbitraryUnicodeText range
|
||||
|
||||
genAnnComputedFieldBolExp ::
|
||||
MonadGen m =>
|
||||
Eq (ScalarType b) =>
|
||||
@ -1051,7 +1052,6 @@ genAnnotatedOrderByElement ::
|
||||
m (TableName b) ->
|
||||
m (ScalarType b) ->
|
||||
m (FunctionName b) ->
|
||||
m (Identifier b) ->
|
||||
m (XComputedField b) ->
|
||||
m (BooleanOperators b a) ->
|
||||
m a ->
|
||||
@ -1080,7 +1080,6 @@ genAnnotatedOrderByElement
|
||||
genTableName
|
||||
genScalarType
|
||||
genFunctionName
|
||||
genIdentifier
|
||||
genXComputedField
|
||||
genBooleanOperators
|
||||
genA
|
||||
@ -1157,7 +1156,6 @@ genAnnotatedOrderByElement
|
||||
genTableName
|
||||
genScalarType
|
||||
genFunctionName
|
||||
genIdentifier
|
||||
genXComputedField
|
||||
genBooleanOperators
|
||||
genA
|
||||
@ -1228,7 +1226,6 @@ genAnnotatedOrderByElement
|
||||
genScalarType
|
||||
genTableName
|
||||
genFunctionName
|
||||
genIdentifier
|
||||
genXComputedField
|
||||
genBooleanOperators
|
||||
genA
|
||||
@ -1301,7 +1298,6 @@ genComputedFieldOrderBy ::
|
||||
m (ScalarType b) ->
|
||||
m (TableName b) ->
|
||||
m (FunctionName b) ->
|
||||
m (Identifier b) ->
|
||||
m (XComputedField b) ->
|
||||
m (BooleanOperators b a) ->
|
||||
m a ->
|
||||
@ -1329,7 +1325,6 @@ genComputedFieldOrderBy
|
||||
genScalarType
|
||||
genTableName
|
||||
genFunctionName
|
||||
genIdentifier
|
||||
genXComputedField
|
||||
genBooleanOperators
|
||||
genA
|
||||
@ -1356,7 +1351,7 @@ genComputedFieldOrderBy
|
||||
<*> genComputedFieldName fieldNameRange
|
||||
<*> genFunctionName
|
||||
<*> genFunctionArgsExpG
|
||||
(genArgumentExp genIdentifier genA)
|
||||
(genArgumentExp genA)
|
||||
funcArgPosRange
|
||||
funcArgNameRange
|
||||
funcArgNamedRange
|
||||
|
@ -1,6 +1,5 @@
|
||||
module Hasura.RQL.IR.Postgres
|
||||
( genTableName,
|
||||
genIdentifier,
|
||||
genFunctionName,
|
||||
genColumn,
|
||||
genScalarType,
|
||||
@ -29,9 +28,6 @@ genTableName :: MonadGen m => Range Int -> m (TableName ('Postgres 'Vanilla))
|
||||
genTableName textRange =
|
||||
PG.QualifiedObject <$> genSchemaName textRange <*> genPgTableName textRange
|
||||
|
||||
genIdentifier :: MonadGen m => Range Int -> m (Identifier ('Postgres 'Vanilla))
|
||||
genIdentifier textRange = PG.Identifier <$> genArbitraryUnicodeText textRange
|
||||
|
||||
genFunctionName :: MonadGen m => Range Int -> m (FunctionName ('Postgres 'Vanilla))
|
||||
genFunctionName textRange =
|
||||
PG.QualifiedObject <$> genSchemaName textRange <*> genPgFunctionName textRange
|
||||
@ -161,7 +157,6 @@ genAnnSelectG ::
|
||||
genAnnSelectG textRange genA =
|
||||
IRGen.genAnnSelectG
|
||||
(genTableName textRange)
|
||||
(genIdentifier textRange)
|
||||
(genFunctionName textRange)
|
||||
(genColumn textRange)
|
||||
(genScalarType textRange)
|
||||
|
Loading…
Reference in New Issue
Block a user