mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 20:41:49 +03:00
80cbf3ae33
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5434 GitOrigin-RevId: 839a45a1469272def9d28c0f3e7454a5bf506f35
46 lines
1.5 KiB
Haskell
46 lines
1.5 KiB
Haskell
module Test.Parser.Delete
|
|
( AnnotatedDeleteBuilder (..),
|
|
mkAnnotatedDelete,
|
|
)
|
|
where
|
|
|
|
import Hasura.Backends.Postgres.SQL.Types (QualifiedTable)
|
|
import Hasura.Prelude
|
|
import Hasura.RQL.IR.BoolExp (GBoolExp (..), OpExpG)
|
|
import Hasura.RQL.IR.Delete (AnnDelG (..))
|
|
import Hasura.RQL.IR.Returning (MutationOutputG (..))
|
|
import Hasura.RQL.IR.Value (UnpreparedValue)
|
|
import Hasura.RQL.Types.Column (ColumnInfo)
|
|
import Hasura.RQL.Types.Instances ()
|
|
import Hasura.SQL.Backend (BackendType (Postgres), PostgresKind (Vanilla))
|
|
import Test.Parser.Expectation qualified as E
|
|
|
|
type PG = 'Postgres 'Vanilla
|
|
|
|
type Output = MutationOutputG PG Void (UnpreparedValue PG)
|
|
|
|
-- | Internal use only. The intended use is through
|
|
-- 'Test.Parser.Expectation.runTest'.
|
|
--
|
|
-- Build an 'AnnDelG', to be used with 'mkAnnotatedDelete'.
|
|
data AnnotatedDeleteBuilder = AnnotatedDeleteBuilder
|
|
{ -- | the main table for the update
|
|
adbTable :: QualifiedTable,
|
|
-- | the where clause(s)
|
|
adbWhere :: [(ColumnInfo PG, [OpExpG PG (UnpreparedValue PG)])],
|
|
-- | the 'Output' clause, e.g., selection set, affected_rows, etc.
|
|
adbOutput :: Output,
|
|
-- | the table columns (all of them)
|
|
adbColumns :: [ColumnInfo PG]
|
|
}
|
|
|
|
mkAnnotatedDelete :: AnnotatedDeleteBuilder -> AnnDelG PG Void (UnpreparedValue PG)
|
|
mkAnnotatedDelete AnnotatedDeleteBuilder {..} =
|
|
AnnDel
|
|
{ _adTable = adbTable,
|
|
_adWhere = (BoolAnd [], E.toBoolExp adbWhere),
|
|
_adOutput = adbOutput,
|
|
_adAllCols = adbColumns,
|
|
_adNamingConvention = Nothing
|
|
}
|