@@ -104,7 +104,7 @@ import Squeal.PostgreSQL.Schema
104104statements
105105-----------------------------------------}
106106
107−-- | A `Definition` is a statement that changes the schema of the
107+-- | A `Definition` is a statement that changes the schemas of the
108108-- database, like a `createTable`, `dropTable`, or `alterTable` command.
109109-- `Definition`s may be composed using the `>>>` operator.
110110newtype Definition
@@ -219,7 +219,7 @@ renderCreation tab columns constraints = renderQualifiedAlias tab
219219 renderCommaSeparated renderConstraint constraints ) )
220220 <> ";"
221221 where
222− renderColumnDef :: Aliased (ColumnTypeExpression schema) x -> ByteString
222+ renderColumnDef :: Aliased (ColumnTypeExpression db) x -> ByteString
223223 renderColumnDef (ty `As` column) =
224224 renderAlias column <+> renderColumnTypeExpression ty
225225 renderConstraint
@@ -741,8 +741,8 @@ newtype AlterColumn (db :: DBType) (ty0 :: ColumnType) (ty1 :: ColumnType) =
741741-- :}
742742-- ALTER TABLE "tab" ALTER COLUMN "col" SET DEFAULT 5;
743743setDefault
744− :: Expression schema '[] 'Ungrouped '[] ty -- ^ default value to set
745− -> AlterColumn schema (constraint :=> ty) ('Def :=> ty)
744+ :: Expression db '[] 'Ungrouped '[] ty -- ^ default value to set
745+ -> AlterColumn db (constraint :=> ty) ('Def :=> ty)
746746setDefault expression = UnsafeAlterColumn $
747747 "SET DEFAULT" <+> renderExpression expression
748748
@@ -757,7 +757,7 @@ setDefault expression = UnsafeAlterColumn $
757757-- in printSQL definition
758758-- :}
759759-- ALTER TABLE "tab" ALTER COLUMN "col" DROP DEFAULT;
760−dropDefault :: AlterColumn schema ('Def :=> ty) ('NoDef :=> ty)
760+dropDefault :: AlterColumn db ('Def :=> ty) ('NoDef :=> ty)
761761dropDefault = UnsafeAlterColumn $ "DROP DEFAULT"
762762
763763-- | A `setNotNull` adds a @NOT NULL@ constraint to a column.
@@ -774,7 +774,7 @@ dropDefault = UnsafeAlterColumn $ "DROP DEFAULT"
774774-- :}
775775-- ALTER TABLE "tab" ALTER COLUMN "col" SET NOT NULL;
776776setNotNull
777− :: AlterColumn schema (constraint :=> 'Null ty) (constraint :=> 'NotNull ty)
777+ :: AlterColumn db (constraint :=> 'Null ty) (constraint :=> 'NotNull ty)
778778setNotNull = UnsafeAlterColumn $ "SET NOT NULL"
779779
780780-- | A `dropNotNull` drops a @NOT NULL@ constraint from a column.
@@ -789,7 +789,7 @@ setNotNull = UnsafeAlterColumn $ "SET NOT NULL"
789789-- :}
790790-- ALTER TABLE "tab" ALTER COLUMN "col" DROP NOT NULL;
791791dropNotNull
792− :: AlterColumn schema (constraint :=> 'NotNull ty) (constraint :=> 'Null ty)
792+ :: AlterColumn db (constraint :=> 'NotNull ty) (constraint :=> 'Null ty)
793793dropNotNull = UnsafeAlterColumn $ "DROP NOT NULL"
794794
795795-- | An `alterType` converts a column to a different data type.
@@ -806,7 +806,7 @@ dropNotNull = UnsafeAlterColumn $ "DROP NOT NULL"
806806-- in printSQL definition
807807-- :}
808808-- ALTER TABLE "tab" ALTER COLUMN "col" TYPE numeric NOT NULL;
809−alterType :: ColumnTypeExpression schema ty -> AlterColumn schema ty0 ty
809+alterType :: ColumnTypeExpression db ty -> AlterColumn db ty0 ty
810810alterType ty = UnsafeAlterColumn $ "TYPE" <+> renderColumnTypeExpression ty
811811
812812-- | Create a view.
@@ -823,7 +823,7 @@ alterType ty = UnsafeAlterColumn $ "TYPE" <+> renderColumnTypeExpression ty
823823-- :}
824824-- CREATE VIEW "bc" AS SELECT "b" AS "b", "c" AS "c" FROM "abc" AS "abc";
825825createView
826− :: (KnownSymbol sch, KnownSymbol vw)
826+ :: (KnownSymbol sch, KnownSymbol vw, Has sch db schema)
827827 => QualifiedAlias sch vw -- ^ the name of the view to add
828828 -> Query db '[] view
829829 -- ^ query
@@ -913,7 +913,7 @@ createTypeComposite ty fields = UnsafeDefinition $
913913 "CREATE" <+> "TYPE" <+> renderQualifiedAlias ty <+> "AS" <+> parenthesized
914914 (renderCommaSeparated renderField fields) <> ";"
915915 where
916− renderField :: Aliased (TypeExpression schema) x -> ByteString
916+ renderField :: Aliased (TypeExpression db) x -> ByteString
917917 renderField (typ `As` alias) =
918918 renderAlias alias <+> renderTypeExpression typ
919919
@@ -936,10 +936,10 @@ createTypeCompositeFrom ty = createTypeComposite ty
936936 (SOP.hcpure (SOP.Proxy :: SOP.Proxy (FieldTyped db)) fieldtype
937937 :: NP (Aliased (TypeExpression db)) (RowPG hask))
938938
939−class FieldTyped schema ty where
940− fieldtype :: Aliased (TypeExpression schema) ty
941−instance (KnownSymbol alias, PGTyped schema ty)
942− => FieldTyped schema (alias ::: ty) where
939+class FieldTyped db ty where
940+ fieldtype :: Aliased (TypeExpression db) ty
941+instance (KnownSymbol alias, PGTyped db ty)
942+ => FieldTyped db (alias ::: ty) where
943943 fieldtype = pgtype `As` Alias
944944
945945-- | Drop a type.
@@ -971,33 +971,33 @@ nullable ty = UnsafeColumnTypeExpression $ renderTypeExpression ty <+> "NULL"
971971-- | used in `createTable` commands as a column constraint to ensure
972972-- @NULL@ is not present in a column
973973notNullable
974− :: TypeExpression schema (nullity ty)
975− -> ColumnTypeExpression schema ('NoDef :=> 'NotNull ty)
974+ :: TypeExpression db (nullity ty)
975+ -> ColumnTypeExpression db ('NoDef :=> 'NotNull ty)
976976notNullable ty = UnsafeColumnTypeExpression $ renderTypeExpression ty <+> "NOT NULL"
977977
978978-- | used in `createTable` commands as a column constraint to give a default
979979default_
980− :: Expression schema '[] 'Ungrouped '[] ty
981− -> ColumnTypeExpression schema ('NoDef :=> ty)
982− -> ColumnTypeExpression schema ('Def :=> ty)
980+ :: Expression db '[] 'Ungrouped '[] ty
981+ -> ColumnTypeExpression db ('NoDef :=> ty)
982+ -> ColumnTypeExpression db ('Def :=> ty)
983983default_ x ty = UnsafeColumnTypeExpression $
984984 renderColumnTypeExpression ty <+> "DEFAULT" <+> renderExpression x
985985
986986-- | not a true type, but merely a notational convenience for creating
987987-- unique identifier columns with type `PGint2`
988988serial2, smallserial
989− :: ColumnTypeExpression schema ('Def :=> 'NotNull 'PGint2)
989+ :: ColumnTypeExpression db ('Def :=> 'NotNull 'PGint2)
990990serial2 = UnsafeColumnTypeExpression "serial2"
991991smallserial = UnsafeColumnTypeExpression "smallserial"
992992-- | not a true type, but merely a notational convenience for creating
993993-- unique identifier columns with type `PGint4`
994994serial4, serial
995− :: ColumnTypeExpression schema ('Def :=> 'NotNull 'PGint4)
995+ :: ColumnTypeExpression db ('Def :=> 'NotNull 'PGint4)
996996serial4 = UnsafeColumnTypeExpression "serial4"
997997serial = UnsafeColumnTypeExpression "serial"
998998-- | not a true type, but merely a notational convenience for creating
999999-- unique identifier columns with type `PGint8`
10001000serial8, bigserial
1001− :: ColumnTypeExpression schema ('Def :=> 'NotNull 'PGint8)
1001+ :: ColumnTypeExpression db ('Def :=> 'NotNull 'PGint8)
10021002serial8 = UnsafeColumnTypeExpression "serial8"
10031003bigserial = UnsafeColumnTypeExpression "bigserial"