@@ -110,12 +110,12 @@ statements
110110-- database, like a `createTable`, `dropTable`, or `alterTable` command.
111111-- `Definition`s may be composed using the `>>>` operator.
112112newtype Definition
113− (db0 :: DBType)
114− (db1 :: DBType)
113+ (schemas0 :: SchemasType)
114+ (schemas1 :: SchemasType)
115115 = UnsafeDefinition { renderDefinition :: ByteString }
116116 deriving (GHC.Generic,Show,Eq,Ord,NFData)
117117
118−instance RenderSQL (Definition db0 db1) where
118+instance RenderSQL (Definition schemas0 schemas1) where
119119 renderSQL = renderDefinition
120120
121121instance Category Definition where
@@ -130,14 +130,14 @@ CREATE statements
130130createSchema
131131 :: KnownSymbol sch
132132 => Alias sch
133− -> Definition db (Create sch '[] db)
133+ -> Definition schemas (Create sch '[] schemas)
134134createSchema sch = UnsafeDefinition $
135135 "CREATE" <+> "SCHEMA" <+> renderAlias sch <> ";"
136136
137137createSchemaIfNotExists
138− :: (KnownSymbol sch, Has sch db schema)
138+ :: (KnownSymbol sch, Has sch schemas schema)
139139 => Alias sch
140− -> Definition db db
140+ -> Definition schemas schemas
141141createSchemaIfNotExists sch = UnsafeDefinition $
142142 "CREATE" <+> "SCHEMA" <+> "IF" <+> "NOT" <+> "EXISTS"
143143 <+> renderAlias sch <> ";"
@@ -166,14 +166,14 @@ createTable
166166 , columns ~ (col ': cols)
167167 , SOP.SListI columns
168168 , SOP.SListI constraints
169− , Has sch db0 schema0
170− , db1 ~ Alter sch (Create tab ('Table (constraints :=> columns)) schema0) db0 )
169+ , Has sch schemas0 schema0
170+ , schemas1 ~ Alter sch (Create tab ('Table (constraints :=> columns)) schema0) schemas0 )
171171 => QualifiedAlias sch tab -- ^ the name of the table to add
172− -> NP (Aliased (ColumnTypeExpression db0)) columns
172+ -> NP (Aliased (ColumnTypeExpression schemas0)) columns
173173 -- ^ the names and datatype of each column
174− -> NP (Aliased (TableConstraintExpression sch tab db1)) constraints
174+ -> NP (Aliased (TableConstraintExpression sch tab schemas1)) constraints
175175 -- ^ constraints that must hold for the table
176− -> Definition db0 db1
176+ -> Definition schemas0 schemas1
177177createTable tab columns constraints = UnsafeDefinition $
178178 "CREATE TABLE" <+> renderCreation tab columns constraints
179179
@@ -201,16 +201,16 @@ in printSQL setup
201201CREATE TABLE IF NOT EXISTS "tab" ("a" int NULL, "b" real NULL);
202202-}
203203createTableIfNotExists
204− :: ( Has sch db schema
204+ :: ( Has sch schemas schema
205205 , Has tab schema ('Table (constraints :=> columns))
206206 , SOP.SListI columns
207207 , SOP.SListI constraints )
208208 => QualifiedAlias sch tab -- ^ the name of the table to add
209− -> NP (Aliased (ColumnTypeExpression db)) columns
209+ -> NP (Aliased (ColumnTypeExpression schemas)) columns
210210 -- ^ the names and datatype of each column
211− -> NP (Aliased (TableConstraintExpression sch tab db)) constraints
211+ -> NP (Aliased (TableConstraintExpression sch tab schemas)) constraints
212212 -- ^ constraints that must hold for the table
213− -> Definition db db
213+ -> Definition schemas schemas
214214createTableIfNotExists tab columns constraints = UnsafeDefinition $
215215 "CREATE TABLE IF NOT EXISTS"
216216 <+> renderCreation tab columns constraints
@@ -222,9 +222,9 @@ renderCreation
222222 , SOP.SListI columns
223223 , SOP.SListI constraints )
224224 => QualifiedAlias sch tab -- ^ the name of the table to add
225− -> NP (Aliased (ColumnTypeExpression db0)) columns
225+ -> NP (Aliased (ColumnTypeExpression schemas0)) columns
226226 -- ^ the names and datatype of each column
227− -> NP (Aliased (TableConstraintExpression sch tab db1)) constraints
227+ -> NP (Aliased (TableConstraintExpression sch tab schemas1)) constraints
228228 -- ^ constraints that must hold for the table
229229 -> ByteString
230230renderCreation tab columns constraints = renderQualifiedAlias tab
@@ -236,11 +236,11 @@ renderCreation tab columns constraints = renderQualifiedAlias tab
236236 renderCommaSeparated renderConstraint constraints ) )
237237 <> ";"
238238 where
239− renderColumnDef :: Aliased (ColumnTypeExpression db) x -> ByteString
239+ renderColumnDef :: Aliased (ColumnTypeExpression schemas) x -> ByteString
240240 renderColumnDef (ty `As` column) =
241241 renderAlias column <+> renderColumnTypeExpression ty
242242 renderConstraint
243− :: Aliased (TableConstraintExpression sch tab db) constraint
243+ :: Aliased (TableConstraintExpression sch tab schemas) constraint
244244 -> ByteString
245245 renderConstraint (constraint `As` alias) =
246246 "CONSTRAINT" <+> renderAlias alias <+> renderTableConstraintExpression constraint
@@ -260,7 +260,7 @@ renderCreation tab columns constraints = renderQualifiedAlias tab
260260newtype TableConstraintExpression
261261 (sch :: Symbol)
262262 (tab :: Symbol)
263− (db :: DBType)
263+ (schemas :: SchemasType)
264264 (constraint :: TableConstraint)
265265 = UnsafeTableConstraintExpression
266266 { renderTableConstraintExpression :: ByteString }
@@ -291,14 +291,14 @@ let
291291CREATE TABLE "tab" ("a" int NOT NULL, "b" int NOT NULL, CONSTRAINT "inequality" CHECK (("a" > "b")));
292292-}
293293check
294− :: ( Has sch db schema
294+ :: ( Has sch schemas schema
295295 , Has tab schema ('Table table)
296296 , HasAll aliases (TableToRow table) subcolumns )
297297 => NP Alias aliases
298298 -- ^ specify the subcolumns which are getting checked
299− -> (forall t. Condition db '[t ::: subcolumns] 'Ungrouped '[])
299+ -> (forall t. Condition ('[] :=> schemas) '[t ::: subcolumns] 'Ungrouped '[])
300300 -- ^ a closed `Condition` on those subcolumns
301− -> TableConstraintExpression sch tab db ('Check aliases)
301+ -> TableConstraintExpression sch tab schemas ('Check aliases)
302302check _cols condition = UnsafeTableConstraintExpression $
303303 "CHECK" <+> parenthesized (renderExpression condition)
304304
@@ -326,12 +326,12 @@ let
326326CREATE TABLE "tab" ("a" int NULL, "b" int NULL, CONSTRAINT "uq_a_b" UNIQUE ("a", "b"));
327327-}
328328unique
329− :: ( Has sch db schema
329+ :: ( Has sch schemas schema
330330 , Has tab schema('Table table)
331331 , HasAll aliases (TableToRow table) subcolumns )
332332 => NP Alias aliases
333333 -- ^ specify subcolumns which together are unique for each row
334− -> TableConstraintExpression sch tab db ('Unique aliases)
334+ -> TableConstraintExpression sch tab schemas ('Unique aliases)
335335unique columns = UnsafeTableConstraintExpression $
336336 "UNIQUE" <+> parenthesized (commaSeparated (renderAliases columns))
337337
@@ -361,13 +361,13 @@ let
361361CREATE TABLE "tab" ("id" serial, "name" text NOT NULL, CONSTRAINT "pk_id" PRIMARY KEY ("id"));
362362-}
363363primaryKey
364− :: ( Has sch db schema
364+ :: ( Has sch schemas schema
365365 , Has tab schema ('Table table)
366366 , HasAll aliases (TableToColumns table) subcolumns
367367 , AllNotNull subcolumns )
368368 => NP Alias aliases
369369 -- ^ specify the subcolumns which together form a primary key.
370− -> TableConstraintExpression sch tab db ('PrimaryKey aliases)
370+ -> TableConstraintExpression sch tab schemas ('PrimaryKey aliases)
371371primaryKey columns = UnsafeTableConstraintExpression $
372372 "PRIMARY KEY" <+> parenthesized (commaSeparated (renderAliases columns))
373373
@@ -445,7 +445,7 @@ in printSQL setup
445445CREATE TABLE "employees" ("id" serial, "name" text NOT NULL, "employer_id" integer NULL, CONSTRAINT "employees_pk" PRIMARY KEY ("id"), CONSTRAINT "employees_employer_fk" FOREIGN KEY ("employer_id") REFERENCES "employees" ("id") ON DELETE CASCADE ON UPDATE CASCADE);
446446-}
447447foreignKey
448− :: (ForeignKeyed db sch schema child parent
448+ :: (ForeignKeyed schemas sch schema child parent
449449 table reftable
450450 columns refcolumns
451451 constraints cols
@@ -460,7 +460,7 @@ foreignKey
460460 -- ^ what to do when reference is deleted
461461 -> OnUpdateClause
462462 -- ^ what to do when reference is updated
463− -> TableConstraintExpression sch child db
463+ -> TableConstraintExpression sch child schemas
464464 ('ForeignKey columns parent refcolumns)
465465foreignKey keys parent refs ondel onupd = UnsafeTableConstraintExpression $
466466 "FOREIGN KEY" <+> parenthesized (commaSeparated (renderAliases keys))
@@ -470,7 +470,7 @@ foreignKey keys parent refs ondel onupd = UnsafeTableConstraintExpression $
470470 <+> renderOnUpdateClause onupd
471471
472472-- | A constraint synonym between types involved in a foreign key constraint.
473−type ForeignKeyed db
473+type ForeignKeyed schemas
474474 sch
475475 schema
476476 child parent
@@ -478,7 +478,7 @@ type ForeignKeyed db
478478 columns refcolumns
479479 constraints cols
480480 reftys tys =
481− ( Has sch db schema
481+ ( Has sch schemas schema
482482 , Has child schema ('Table table)
483483 , Has parent schema ('Table reftable)
484484 , HasAll columns (TableToColumns table) tys
@@ -541,10 +541,10 @@ DROP statements
541541-- >>> printSQL definition
542542-- DROP TABLE "muh_table";
543543dropTable
544− :: ( Has sch db schema
544+ :: ( Has sch schemas schema
545545 , Has tab schema ('Table table))
546546 => QualifiedAlias sch tab -- ^ table to remove
547− -> Definition db (Alter sch (Drop tab schema) db)
547+ -> Definition schemas (Alter sch (Drop tab schema) schemas)
548548dropTable tab = UnsafeDefinition $ "DROP TABLE" <+> renderQualifiedAlias tab <> ";"
549549
550550{-----------------------------------------
@@ -553,10 +553,10 @@ ALTER statements
553553
554554-- | `alterTable` changes the definition of a table from the schema.
555555alterTable
556− :: (Has sch db schema, Has tab schema ('Table table0))
556+ :: (Has sch schemas schema, Has tab schema ('Table table0))
557557 => QualifiedAlias sch tab -- ^ table to alter
558− -> AlterTable sch tab db table1 -- ^ alteration to perform
559− -> Definition db (Alter sch (Alter tab ('Table table1) schema) db)
558+ -> AlterTable sch tab schemas table1 -- ^ alteration to perform
559+ -> Definition schemas (Alter sch (Alter tab ('Table table1) schema) schemas)
560560alterTable tab alteration = UnsafeDefinition $
561561 "ALTER TABLE"
562562 <+> renderQualifiedAlias tab
@@ -581,7 +581,7 @@ alterTableRename table0 table1 = UnsafeDefinition $
581581newtype AlterTable
582582 (sch :: Symbol)
583583 (tab :: Symbol)
584− (db :: DBType)
584+ (schemas :: SchemasType)
585585 (table :: TableType) =
586586 UnsafeAlterTable {renderAlterTable :: ByteString}
587587 deriving (GHC.Generic,Show,Eq,Ord,NFData)
@@ -599,14 +599,14 @@ newtype AlterTable
599599-- ALTER TABLE "tab" ADD CONSTRAINT "positive" CHECK (("col" > 0));
600600addConstraint
601601 :: ( KnownSymbol alias
602− , Has sch db schema
602+ , Has sch schemas schema
603603 , Has tab schema ('Table table0)
604604 , table0 ~ (constraints :=> columns)
605605 , table1 ~ (Create alias constraint constraints :=> columns) )
606606 => Alias alias
607− -> TableConstraintExpression sch tab db constraint
607+ -> TableConstraintExpression sch tab schemas constraint
608608 -- ^ constraint to add
609− -> AlterTable sch tab db table1
609+ -> AlterTable sch tab schemas table1
610610addConstraint alias constraint = UnsafeAlterTable $
611611 "ADD" <+> "CONSTRAINT" <+> renderAlias alias
612612 <+> renderTableConstraintExpression constraint
@@ -624,13 +624,13 @@ addConstraint alias constraint = UnsafeAlterTable $
624624-- ALTER TABLE "tab" DROP CONSTRAINT "positive";
625625dropConstraint
626626 :: ( KnownSymbol constraint
627− , Has sch db schema
627+ , Has sch schemas schema
628628 , Has tab schema ('Table table0)
629629 , table0 ~ (constraints :=> columns)
630630 , table1 ~ (Drop constraint constraints :=> columns) )
631631 => Alias constraint
632632 -- ^ constraint to drop
633− -> AlterTable sch tab db table1
633+ -> AlterTable sch tab schemas table1
634634dropConstraint constraint = UnsafeAlterTable $
635635 "DROP" <+> "CONSTRAINT" <+> renderAlias constraint
636636
@@ -664,12 +664,12 @@ class AddColumn ty where
664664 -- ALTER TABLE "tab" ADD COLUMN "col2" text NULL;
665665 addColumn
666666 :: ( KnownSymbol column
667− , Has sch db schema
667+ , Has sch schemas schema
668668 , Has tab schema ('Table table0)
669669 , table0 ~ (constraints :=> columns) )
670670 => Alias column -- ^ column to add
671− -> ColumnTypeExpression db ty -- ^ type of the new column
672− -> AlterTable sch tab db (constraints :=> Create column ty columns)
671+ -> ColumnTypeExpression schemas ty -- ^ type of the new column
672+ -> AlterTable sch tab schemas (constraints :=> Create column ty columns)
673673 addColumn column ty = UnsafeAlterTable $
674674 "ADD COLUMN" <+> renderAlias column <+> renderColumnTypeExpression ty
675675instance {-# OVERLAPPING #-} AddColumn ('Def :=> ty)
@@ -693,12 +693,12 @@ instance {-# OVERLAPPABLE #-} AddColumn ('NoDef :=> 'Null ty)
693693-- ALTER TABLE "tab" DROP COLUMN "col2";
694694dropColumn
695695 :: ( KnownSymbol column
696− , Has sch db schema
696+ , Has sch schemas schema
697697 , Has tab schema ('Table table0)
698698 , table0 ~ (constraints :=> columns)
699699 , table1 ~ (constraints :=> Drop column columns) )
700700 => Alias column -- ^ column to remove
701− -> AlterTable sch tab db table1
701+ -> AlterTable sch tab schemas table1
702702dropColumn column = UnsafeAlterTable $
703703 "DROP COLUMN" <+> renderAlias column
704704
@@ -716,32 +716,32 @@ dropColumn column = UnsafeAlterTable $
716716renameColumn
717717 :: ( KnownSymbol column0
718718 , KnownSymbol column1
719− , Has sch db schema
719+ , Has sch schemas schema
720720 , Has tab schema ('Table table0)
721721 , table0 ~ (constraints :=> columns)
722722 , table1 ~ (constraints :=> Rename column0 column1 columns) )
723723 => Alias column0 -- ^ column to rename
724724 -> Alias column1 -- ^ what to rename the column
725− -> AlterTable sch tab db table1
725+ -> AlterTable sch tab schemas table1
726726renameColumn column0 column1 = UnsafeAlterTable $
727727 "RENAME COLUMN" <+> renderAlias column0 <+> "TO" <+> renderAlias column1
728728
729729-- | An `alterColumn` alters a single column.
730730alterColumn
731731 :: ( KnownSymbol column
732− , Has sch db schema
732+ , Has sch schemas schema
733733 , Has tab schema ('Table table0)
734734 , table0 ~ (constraints :=> columns)
735735 , Has column columns ty0
736736 , tables1 ~ (constraints :=> Alter column ty1 columns))
737737 => Alias column -- ^ column to alter
738− -> AlterColumn db ty0 ty1 -- ^ alteration to perform
739− -> AlterTable sch tab db table1
738+ -> AlterColumn schemas ty0 ty1 -- ^ alteration to perform
739+ -> AlterTable sch tab schemas table1
740740alterColumn column alteration = UnsafeAlterTable $
741741 "ALTER COLUMN" <+> renderAlias column <+> renderAlterColumn alteration
742742
743743-- | An `AlterColumn` describes the alteration to perform on a single column.
744−newtype AlterColumn (db :: DBType) (ty0 :: ColumnType) (ty1 :: ColumnType) =
744+newtype AlterColumn (schemas :: SchemasType) (ty0 :: ColumnType) (ty1 :: ColumnType) =
745745 UnsafeAlterColumn {renderAlterColumn :: ByteString}
746746 deriving (GHC.Generic,Show,Eq,Ord,NFData)
747747
@@ -759,8 +759,8 @@ newtype AlterColumn (db :: DBType) (ty0 :: ColumnType) (ty1 :: ColumnType) =
759759-- :}
760760-- ALTER TABLE "tab" ALTER COLUMN "col" SET DEFAULT 5;
761761setDefault
762− :: Expression db '[] 'Ungrouped '[] ty -- ^ default value to set
763− -> AlterColumn db (constraint :=> ty) ('Def :=> ty)
762+ :: Expression ('[] :=> schemas) '[] 'Ungrouped '[] ty -- ^ default value to set
763+ -> AlterColumn schemas (constraint :=> ty) ('Def :=> ty)
764764setDefault expression = UnsafeAlterColumn $
765765 "SET DEFAULT" <+> renderExpression expression
766766
@@ -775,7 +775,7 @@ setDefault expression = UnsafeAlterColumn $
775775-- in printSQL definition
776776-- :}
777777-- ALTER TABLE "tab" ALTER COLUMN "col" DROP DEFAULT;
778−dropDefault :: AlterColumn db ('Def :=> ty) ('NoDef :=> ty)
778+dropDefault :: AlterColumn schemas ('Def :=> ty) ('NoDef :=> ty)
779779dropDefault = UnsafeAlterColumn $ "DROP DEFAULT"
780780
781781-- | A `setNotNull` adds a @NOT NULL@ constraint to a column.
@@ -792,7 +792,7 @@ dropDefault = UnsafeAlterColumn $ "DROP DEFAULT"
792792-- :}
793793-- ALTER TABLE "tab" ALTER COLUMN "col" SET NOT NULL;
794794setNotNull
795− :: AlterColumn db (constraint :=> 'Null ty) (constraint :=> 'NotNull ty)
795+ :: AlterColumn schemas (constraint :=> 'Null ty) (constraint :=> 'NotNull ty)
796796setNotNull = UnsafeAlterColumn $ "SET NOT NULL"
797797
798798-- | A `dropNotNull` drops a @NOT NULL@ constraint from a column.
@@ -807,7 +807,7 @@ setNotNull = UnsafeAlterColumn $ "SET NOT NULL"
807807-- :}
808808-- ALTER TABLE "tab" ALTER COLUMN "col" DROP NOT NULL;
809809dropNotNull
810− :: AlterColumn db (constraint :=> 'NotNull ty) (constraint :=> 'Null ty)
810+ :: AlterColumn schemas (constraint :=> 'NotNull ty) (constraint :=> 'Null ty)
811811dropNotNull = UnsafeAlterColumn $ "DROP NOT NULL"
812812
813813-- | An `alterType` converts a column to a different data type.
@@ -824,7 +824,7 @@ dropNotNull = UnsafeAlterColumn $ "DROP NOT NULL"
824824-- in printSQL definition
825825-- :}
826826-- ALTER TABLE "tab" ALTER COLUMN "col" TYPE numeric NOT NULL;
827−alterType :: ColumnTypeExpression db ty -> AlterColumn db ty0 ty
827+alterType :: ColumnTypeExpression schemas ty -> AlterColumn schemas ty0 ty
828828alterType ty = UnsafeAlterColumn $ "TYPE" <+> renderColumnTypeExpression ty
829829
830830{- | Create a view.
@@ -842,10 +842,10 @@ in printSQL definition
842842CREATE VIEW "bc" AS SELECT "b" AS "b", "c" AS "c" FROM "abc" AS "abc";
843843-}
844844createView
845− :: (KnownSymbol sch, KnownSymbol vw, Has sch db schema)
845+ :: (KnownSymbol sch, KnownSymbol vw, Has sch schemas schema)
846846 => QualifiedAlias sch vw -- ^ the name of the view to add
847− -> Query db '[] view -- ^ query
848− -> Definition db (Alter sch (Create vw ('View view) schema) db)
847+ -> Query ('[] :=> schemas) '[] view -- ^ query
848+ -> Definition schemas (Alter sch (Create vw ('View view) schema) schemas)
849849createView alias query = UnsafeDefinition $
850850 "CREATE" <+> "VIEW" <+> renderQualifiedAlias alias <+> "AS"
851851 <+> renderQuery query <> ";"
@@ -863,9 +863,9 @@ createView alias query = UnsafeDefinition $
863863-- :}
864864-- DROP VIEW "bc";
865865dropView
866− :: (Has sch db schema, Has vw schema ('View view))
866+ :: (Has sch schemas schema, Has vw schema ('View view))
867867 => QualifiedAlias sch vw -- ^ view to remove
868− -> Definition db (Alter sch (Drop vw schema) db)
868+ -> Definition schemas (Alter sch (Drop vw schema) schemas)
869869dropView vw = UnsafeDefinition $ "DROP VIEW" <+> renderQualifiedAlias vw <> ";"
870870
871871-- | Enumerated types are created using the `createTypeEnum` command, for example
@@ -873,12 +873,12 @@ dropView vw = UnsafeDefinition $ "DROP VIEW" <+> renderQualifiedAlias vw <> ";"
873873-- >>> printSQL $ (createTypeEnum #mood (label @"sad" :* label @"ok" :* label @"happy") :: Definition '["public" ::: '[]] '["public" ::: '["mood" ::: 'Typedef ('PGenum '["sad","ok","happy"])]])
874874-- CREATE TYPE "mood" AS ENUM ('sad', 'ok', 'happy');
875875createTypeEnum
876− :: (KnownSymbol enum, Has sch db schema, SOP.All KnownSymbol labels)
876+ :: (KnownSymbol enum, Has sch schemas schema, SOP.All KnownSymbol labels)
877877 => QualifiedAlias sch enum
878878 -- ^ name of the user defined enumerated type
879879 -> NP PGlabel labels
880880 -- ^ labels of the enumerated type
881− -> Definition db (Alter sch (Create enum ('Typedef ('PGenum labels)) schema) db)
881+ -> Definition schemas (Alter sch (Create enum ('Typedef ('PGenum labels)) schema) schemas)
882882createTypeEnum enum labels = UnsafeDefinition $
883883 "CREATE" <+> "TYPE" <+> renderQualifiedAlias enum <+> "AS" <+> "ENUM" <+>
884884 parenthesized (commaSeparated (renderLabels labels)) <> ";"
@@ -897,14 +897,14 @@ createTypeEnum enum labels = UnsafeDefinition $
897897-- :}
898898-- CREATE TYPE "schwarma" AS ENUM ('Beef', 'Lamb', 'Chicken');
899899createTypeEnumFrom
900− :: forall hask sch enum db schema.
900+ :: forall hask sch enum schemas schema.
901901 ( SOP.Generic hask
902902 , SOP.All KnownSymbol (LabelsPG hask)
903903 , KnownSymbol enum
904− , Has sch db schema )
904+ , Has sch schemas schema )
905905 => QualifiedAlias sch enum
906906 -- ^ name of the user defined enumerated type
907− -> Definition db (Alter sch (Create enum ('Typedef (PG (Enumerated hask))) schema) db)
907+ -> Definition schemas (Alter sch (Create enum ('Typedef (PG (Enumerated hask))) schema) schemas)
908908createTypeEnumFrom enum = createTypeEnum enum
909909 (SOP.hpure label :: NP PGlabel (LabelsPG hask))
910910
@@ -927,17 +927,17 @@ in printSQL setup
927927CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);
928928-}
929929createTypeComposite
930− :: (KnownSymbol ty, Has sch db schema, SOP.SListI fields)
930+ :: (KnownSymbol ty, Has sch schemas schema, SOP.SListI fields)
931931 => QualifiedAlias sch ty
932932 -- ^ name of the user defined composite type
933− -> NP (Aliased (TypeExpression db)) fields
933+ -> NP (Aliased (TypeExpression schemas)) fields
934934 -- ^ list of attribute names and data types
935− -> Definition db (Alter sch (Create ty ('Typedef ('PGcomposite fields)) schema) db)
935+ -> Definition schemas (Alter sch (Create ty ('Typedef ('PGcomposite fields)) schema) schemas)
936936createTypeComposite ty fields = UnsafeDefinition $
937937 "CREATE" <+> "TYPE" <+> renderQualifiedAlias ty <+> "AS" <+> parenthesized
938938 (renderCommaSeparated renderField fields) <> ";"
939939 where
940− renderField :: Aliased (TypeExpression db) x -> ByteString
940+ renderField :: Aliased (TypeExpression schemas) x -> ByteString
941941 renderField (typ `As` alias) =
942942 renderAlias alias <+> renderTypeExpression typ
943943
@@ -956,21 +956,21 @@ createTypeComposite ty fields = UnsafeDefinition $
956956-- :}
957957-- CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);
958958createTypeCompositeFrom
959− :: forall hask sch ty db schema.
960− ( SOP.All (FieldTyped db) (RowPG hask)
959+ :: forall hask sch ty schemas schema.
960+ ( SOP.All (FieldTyped schemas) (RowPG hask)
961961 , KnownSymbol ty
962− , Has sch db schema )
962+ , Has sch schemas schema )
963963 => QualifiedAlias sch ty
964964 -- ^ name of the user defined composite type
965− -> Definition db (Alter sch (Create ty ( 'Typedef (PG (Composite hask))) schema) db)
965+ -> Definition schemas (Alter sch (Create ty ( 'Typedef (PG (Composite hask))) schema) schemas)
966966createTypeCompositeFrom ty = createTypeComposite ty
967− (SOP.hcpure (SOP.Proxy :: SOP.Proxy (FieldTyped db)) fieldtype
968− :: NP (Aliased (TypeExpression db)) (RowPG hask))
967+ (SOP.hcpure (SOP.Proxy :: SOP.Proxy (FieldTyped schemas)) fieldtype
968+ :: NP (Aliased (TypeExpression schemas)) (RowPG hask))
969969
970−class FieldTyped db ty where
971− fieldtype :: Aliased (TypeExpression db) ty
972−instance (KnownSymbol alias, PGTyped db ty)
973− => FieldTyped db (alias ::: ty) where
970+class FieldTyped schemas ty where
971+ fieldtype :: Aliased (TypeExpression schemas) ty
972+instance (KnownSymbol alias, PGTyped schemas ty)
973+ => FieldTyped schemas (alias ::: ty) where
974974 fieldtype = pgtype `As` Alias
975975
976976-- | Drop a type.
@@ -981,54 +981,54 @@ instance (KnownSymbol alias, PGTyped db ty)
981981-- >>> printSQL (dropType #schwarma :: Definition '["public" ::: '["schwarma" ::: 'Typedef (PG (Enumerated Schwarma))]] '["public" ::: '[]])
982982-- DROP TYPE "schwarma";
983983dropType
984− :: (Has sch db schema, Has td schema ('Typedef ty))
984+ :: (Has sch schemas schema, Has td schema ('Typedef ty))
985985 => QualifiedAlias sch td
986986 -- ^ name of the user defined type
987− -> Definition db (Alter sch (Drop td schema) db)
987+ -> Definition schemas (Alter sch (Drop td schema) schemas)
988988dropType tydef = UnsafeDefinition $ "DROP" <+> "TYPE" <+> renderQualifiedAlias tydef <> ";"
989989
990990-- | `ColumnTypeExpression`s are used in `createTable` commands.
991−newtype ColumnTypeExpression (db :: DBType) (ty :: ColumnType)
991+newtype ColumnTypeExpression (schemas :: SchemasType) (ty :: ColumnType)
992992 = UnsafeColumnTypeExpression { renderColumnTypeExpression :: ByteString }
993993 deriving (GHC.Generic,Show,Eq,Ord,NFData)
994994
995995-- | used in `createTable` commands as a column constraint to note that
996996-- @NULL@ may be present in a column
997997nullable
998− :: TypeExpression db (nullity ty)
999− -> ColumnTypeExpression db ('NoDef :=> 'Null ty)
998+ :: TypeExpression schemas (nullity ty)
999+ -> ColumnTypeExpression schemas ('NoDef :=> 'Null ty)
10001000nullable ty = UnsafeColumnTypeExpression $ renderTypeExpression ty <+> "NULL"
10011001
10021002-- | used in `createTable` commands as a column constraint to ensure
10031003-- @NULL@ is not present in a column
10041004notNullable
1005− :: TypeExpression db (nullity ty)
1006− -> ColumnTypeExpression db ('NoDef :=> 'NotNull ty)
1005+ :: TypeExpression schemas (nullity ty)
1006+ -> ColumnTypeExpression schemas ('NoDef :=> 'NotNull ty)
10071007notNullable ty = UnsafeColumnTypeExpression $ renderTypeExpression ty <+> "NOT NULL"
10081008
10091009-- | used in `createTable` commands as a column constraint to give a default
10101010default_
1011− :: Expression db '[] 'Ungrouped '[] ty
1012− -> ColumnTypeExpression db ('NoDef :=> ty)
1013− -> ColumnTypeExpression db ('Def :=> ty)
1011+ :: Expression ('[] :=> schemas) '[] 'Ungrouped '[] ty
1012+ -> ColumnTypeExpression schemas ('NoDef :=> ty)
1013+ -> ColumnTypeExpression schemas ('Def :=> ty)
10141014default_ x ty = UnsafeColumnTypeExpression $
10151015 renderColumnTypeExpression ty <+> "DEFAULT" <+> renderExpression x
10161016
10171017-- | not a true type, but merely a notational convenience for creating
10181018-- unique identifier columns with type `PGint2`
10191019serial2, smallserial
1020− :: ColumnTypeExpression db ('Def :=> 'NotNull 'PGint2)
1020+ :: ColumnTypeExpression schemas ('Def :=> 'NotNull 'PGint2)
10211021serial2 = UnsafeColumnTypeExpression "serial2"
10221022smallserial = UnsafeColumnTypeExpression "smallserial"
10231023-- | not a true type, but merely a notational convenience for creating
10241024-- unique identifier columns with type `PGint4`
10251025serial4, serial
1026− :: ColumnTypeExpression db ('Def :=> 'NotNull 'PGint4)
1026+ :: ColumnTypeExpression schemas ('Def :=> 'NotNull 'PGint4)
10271027serial4 = UnsafeColumnTypeExpression "serial4"
10281028serial = UnsafeColumnTypeExpression "serial"
10291029-- | not a true type, but merely a notational convenience for creating
10301030-- unique identifier columns with type `PGint8`
10311031serial8, bigserial
1032− :: ColumnTypeExpression db ('Def :=> 'NotNull 'PGint8)
1032+ :: ColumnTypeExpression schemas ('Def :=> 'NotNull 'PGint8)
10331033serial8 = UnsafeColumnTypeExpression "serial8"
10341034bigserial = UnsafeColumnTypeExpression "bigserial"