mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 04:51:35 +03:00
ea5c92acae
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8876 GitOrigin-RevId: abfc18eeef96a1f3593bfe823adab4d161161333
32 lines
844 B
Haskell
32 lines
844 B
Haskell
-- | Postgres Translate Delete
|
|
--
|
|
-- Tranlates an IR delete term to a Postgres SQL DELETE statement.
|
|
--
|
|
-- See 'Hasura.Backends.Postgres.Execute.Mutation.execDeleteQuery'.
|
|
module Hasura.Backends.Postgres.Translate.Delete
|
|
( mkDelete,
|
|
)
|
|
where
|
|
|
|
import Hasura.Backends.Postgres.SQL.DML qualified as S
|
|
import Hasura.Backends.Postgres.Translate.BoolExp
|
|
import Hasura.Prelude
|
|
import Hasura.RQL.IR.BoolExp
|
|
import Hasura.RQL.IR.Delete
|
|
import Hasura.RQL.Types.Backend
|
|
import Hasura.RQL.Types.BackendType
|
|
|
|
mkDelete ::
|
|
Backend ('Postgres pgKind) =>
|
|
AnnDel ('Postgres pgKind) ->
|
|
S.SQLDelete
|
|
mkDelete (AnnDel tn (fltr, wc) _ _ _) =
|
|
S.SQLDelete tn Nothing tableFltr $ Just S.returningStar
|
|
where
|
|
tableFltr =
|
|
Just
|
|
. S.WhereFrag
|
|
. S.simplifyBoolExp
|
|
. toSQLBoolExp (S.QualTable tn)
|
|
$ andAnnBoolExps fltr wc
|