From 2b71e5e046db1b6aaa0b34aa78717272c27a4597 Mon Sep 17 00:00:00 2001 From: Amitai Burstein Date: Tue, 13 Aug 2024 21:25:46 +0300 Subject: [PATCH] Add tests --- Test/IDE/SchemaDesigner/CompilerSpec.hs | 27 +++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Test/IDE/SchemaDesigner/CompilerSpec.hs b/Test/IDE/SchemaDesigner/CompilerSpec.hs index 22a2f3bc4..137e01bf2 100644 --- a/Test/IDE/SchemaDesigner/CompilerSpec.hs +++ b/Test/IDE/SchemaDesigner/CompilerSpec.hs @@ -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 @@ -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" @@ -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 = [ @@ -1067,4 +1067,23 @@ tests = do , check = Just (VarExpression "false") } ] - compileSql statements `shouldBe` sql \ No newline at end of file + 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