on dev help sign in
Merge branch 'dev' into dev-fun
70f2f10Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+15−3
@@ -1078,11 +1078,11 @@ let
1078 setup :: Definition (Public '[]) (Public '["tab" ::: 'Table Table, "ix" ::: 'Index])
1078 setup :: Definition (Public '[]) (Public '["tab" ::: 'Table Table, "ix" ::: 'Index])
1079 setup =
1079 setup =
1080 createTable #tab (nullable int `as` #a :* nullable real `as` #b) Nil >>>
1080 createTable #tab (nullable int `as` #a :* nullable real `as` #b) Nil >>>
1081− createIndex #ix #tab Gin [#a & AscNullsFirst, #b & AscNullsLast]
1081+ createIndex #ix #tab Btree [#a & AscNullsFirst, #b & AscNullsLast]
1082in printSQL setup
1082in printSQL setup
1083:}
1083:}
1084CREATE TABLE "tab" ("a" int NULL, "b" real NULL);
1084CREATE TABLE "tab" ("a" int NULL, "b" real NULL);
1085−CREATE INDEX "ix" ON "tab" USING gin (("a" ASC NULLS FIRST), ("b" ASC NULLS LAST));
1085+CREATE INDEX "ix" ON "tab" USING btree (("a") ASC NULLS FIRST, ("b") ASC NULLS LAST);
1086-}
1086-}
1087createIndex
1087createIndex
1088 :: (Has sch schemas schema, Has tab schema ('Table table), KnownSymbol ix)
1088 :: (Has sch schemas schema, Has tab schema ('Table table), KnownSymbol ix)
@@ -1094,8 +1094,20 @@ createIndex
1094createIndex ix tab method cols = UnsafeDefinition $
1094createIndex ix tab method cols = UnsafeDefinition $
1095 "CREATE" <+> "INDEX" <+> renderSQL ix <+> "ON" <+> renderSQL tab
1095 "CREATE" <+> "INDEX" <+> renderSQL ix <+> "ON" <+> renderSQL tab
1096 <+> "USING" <+> renderSQL method
1096 <+> "USING" <+> renderSQL method
1097− <+> parenthesized (commaSeparated (parenthesized . renderSQL <$> cols))
1097+ <+> parenthesized (commaSeparated (renderIndex <$> cols))
1098 <> ";"
1098 <> ";"
1099+ where
1100+ renderIndex = \case
1101+ Asc expression -> parenthesized (renderSQL expression) <+> "ASC"
1102+ Desc expression -> parenthesized (renderSQL expression) <+> "DESC"
1103+ AscNullsFirst expression -> parenthesized (renderSQL expression)
1104+ <+> "ASC NULLS FIRST"
1105+ DescNullsFirst expression -> parenthesized (renderSQL expression)
1106+ <+> "DESC NULLS FIRST"
1107+ AscNullsLast expression -> parenthesized (renderSQL expression)
1108+ <+> "ASC NULLS LAST"
1109+ DescNullsLast expression -> parenthesized (renderSQL expression)
1110+ <+> "DESC NULLS LAST"
1099
1111
1100data IndexMethod
1112data IndexMethod
1101 = Btree
1113 = Btree