2022-02-08 12:24:34 +03:00
|
|
|
-- | Postgres Translate Delete
|
|
|
|
--
|
|
|
|
-- Tranlates an IR delete term to a Postgres SQL DELETE statement.
|
|
|
|
--
|
|
|
|
-- See 'Hasura.Backends.Postgres.Execute.Mutation.execDeleteQuery'.
|
2020-10-29 19:58:13 +03:00
|
|
|
module Hasura.Backends.Postgres.Translate.Delete
|
2020-11-12 12:25:48 +03:00
|
|
|
( mkDelete,
|
2020-10-29 19:58:13 +03:00
|
|
|
)
|
|
|
|
where
|
|
|
|
|
2020-11-02 14:50:40 +03:00
|
|
|
import Hasura.Backends.Postgres.SQL.DML qualified as S
|
|
|
|
import Hasura.Backends.Postgres.Translate.BoolExp
|
2020-10-29 19:58:13 +03:00
|
|
|
import Hasura.Prelude
|
2022-04-27 16:57:28 +03:00
|
|
|
import Hasura.RQL.IR.BoolExp
|
2020-10-29 19:58:13 +03:00
|
|
|
import Hasura.RQL.IR.Delete
|
2022-04-27 16:57:28 +03:00
|
|
|
import Hasura.RQL.Types.Backend
|
|
|
|
import Hasura.SQL.Backend
|
2020-10-29 19:58:13 +03:00
|
|
|
|
2021-04-22 00:44:37 +03:00
|
|
|
mkDelete ::
|
|
|
|
Backend ('Postgres pgKind) =>
|
|
|
|
AnnDel ('Postgres pgKind) ->
|
|
|
|
S.SQLDelete
|
2022-07-19 09:55:42 +03:00
|
|
|
mkDelete (AnnDel tn (fltr, wc) _ _ _) =
|
2020-11-12 12:25:48 +03:00
|
|
|
S.SQLDelete tn Nothing tableFltr $ Just S.returningStar
|
2020-10-29 19:58:13 +03:00
|
|
|
where
|
|
|
|
tableFltr =
|
2022-08-11 13:45:39 +03:00
|
|
|
Just
|
|
|
|
. S.WhereFrag
|
|
|
|
. S.simplifyBoolExp
|
|
|
|
. toSQLBoolExp (S.QualTable tn)
|
|
|
|
$ andAnnBoolExps fltr wc
|