Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amitaibu committed Aug 13, 2024
1 parent 9bee88c commit 2b71e5e
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions Test/IDE/SchemaDesigner/CompilerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ tests = do
, indexType = Nothing
}
compileSql [statement] `shouldBe` sql

it "should escape an index name inside a 'CREATE INDEX' statement" do
let sql = cs [plain|CREATE INDEX "Some Index" ON "Some Table" ("Some Col");\n|]
let statement = CreateIndex
Expand Down Expand Up @@ -841,7 +841,7 @@ tests = do
)
}
compileSql [policy] `shouldBe` sql

it "should compile 'CREATE POLICY' statements with a 'ihp_user_id() IS NOT NULL' expression" do
-- https://github.com/digitallyinduced/ihp/issues/1412
let sql = "CREATE POLICY \"Users can manage tasks if logged in\" ON tasks USING (ihp_user_id() IS NOT NULL) WITH CHECK (ihp_user_id() IS NOT NULL);\n"
Expand Down Expand Up @@ -1040,7 +1040,7 @@ tests = do
it "should compile 'CREATE UNLOGGED TABLE' statements" do
let sql = [trimming|
CREATE UNLOGGED TABLE pg_large_notifications (

);
|] <> "\n"
let statements = [
Expand All @@ -1067,4 +1067,23 @@ tests = do
, check = Just (VarExpression "false")
}
]
compileSql statements `shouldBe` sql
compileSql statements `shouldBe` sql

it "should compile a CREATE TABLE statement with INHERITS" do
let sql = "CREATE TABLE child_table (\n id UUID PRIMARY KEY\n) INHERITS (parent_table);\n"
let statement = StatementCreateTable CreateTable
{ name = "child_table"
, columns = [Column
{ name = "id"
, columnType = PUUID
, defaultValue = Nothing
, notNull = False
, isUnique = False
, generator = Nothing
}]
, primaryKeyConstraint = PrimaryKeyConstraint ["id"]
, constraints = []
, unlogged = False
, inherits = Just "parent_table"
}
compileSql [statement] `shouldBe` sql

0 comments on commit 2b71e5e

Please sign in to comment.