on dev help sign in
Merge branch 'dev' into dev-fun
commit70f2f10490d383d802740bcf822e5f68a3c6b15f authorEitan Chatav <eitan@EEM109LMBP-1.local> dateMon 2 Sep 2019, 09:46 (7 years ago) parent22fb78ff29788f
1 file changed+15−3
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+15−3
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+15−3
@@ -1078,11 +1078,11 @@ let
10781078 setup :: Definition (Public '[]) (Public '["tab" ::: 'Table Table, "ix" ::: 'Index])
10791079 setup =
10801080 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]
10821082in printSQL setup
10831083:}
10841084CREATE 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);
10861086-}
10871087createIndex
10881088 :: (Has sch schemas schema, Has tab schema ('Table table), KnownSymbol ix)
@@ -1094,8 +1094,20 @@ createIndex
10941094createIndex ix tab method cols = UnsafeDefinition $
10951095 "CREATE" <+> "INDEX" <+> renderSQL ix <+> "ON" <+> renderSQL tab
10961096 <+> "USING" <+> renderSQL method
1097− <+> parenthesized (commaSeparated (parenthesized . renderSQL <$> cols))
1097+ <+> parenthesized (commaSeparated (renderIndex <$> cols))
10981098 <> ";"
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"
10991111
11001112data IndexMethod
11011113 = Btree