mirror of
https://github.com/hasura/graphql-engine.git
synced 2025-01-04 21:52:38 +03:00
7e279b5c56
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5545 GitOrigin-RevId: 74344445aa33983b29e993e4b0cd8a335bce6b93
51 lines
1.4 KiB
Haskell
51 lines
1.4 KiB
Haskell
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
module Hasura.Backends.Postgres.Translate.DeleteSpec
|
|
( spec,
|
|
)
|
|
where
|
|
|
|
import Database.PG.Query.Pool qualified as QQ
|
|
import Hasura.Prelude
|
|
import Hasura.RQL.IR.BoolExp (OpExpG (..))
|
|
import Hasura.RQL.IR.Returning (MutFldG (..), MutationOutputG (..))
|
|
import Test.Backend.Postgres.Delete qualified as Test
|
|
import Test.Backend.Postgres.Misc qualified as P
|
|
import Test.Hspec
|
|
import Test.Parser.Expectation as Expect
|
|
|
|
spec :: Spec
|
|
spec =
|
|
describe "Postgres.Translate.DeleteSpec" do
|
|
Test.runTest
|
|
Test.TestBuilder
|
|
{ name = "delete where id",
|
|
table = Expect.mkTable "test",
|
|
columns = [P.idColumn, P.nameColumn],
|
|
mutationOutput = MOutMultirowFields [("affected_rows", MCount)],
|
|
where_ = [(P.idColumn, [AEQ True P.integerOne])],
|
|
expectedSQL =
|
|
[QQ.sql|
|
|
DELETE FROM "public"."test"
|
|
WHERE
|
|
(("public"."test"."id") = (('1')::integer))
|
|
RETURNING *
|
|
|]
|
|
}
|
|
|
|
Test.runTest
|
|
Test.TestBuilder
|
|
{ name = "delete where column",
|
|
table = Expect.mkTable "test",
|
|
columns = [P.idColumn, P.nameColumn],
|
|
mutationOutput = MOutMultirowFields [("affected_rows", MCount)],
|
|
where_ = [(P.nameColumn, [AEQ True P.textOld])],
|
|
expectedSQL =
|
|
[QQ.sql|
|
|
DELETE FROM "public"."test"
|
|
WHERE
|
|
(("public"."test"."name") = (('old name')::text))
|
|
RETURNING *
|
|
|]
|
|
}
|