@@ -69,8 +69,6 @@ module Squeal.PostgreSQL.Definition
69 , createTypeEnumFromHaskell
69 , createTypeEnumFromHaskell
70 , dropType
70 , dropType
71 , ColumnTypeExpression (..)
71 , ColumnTypeExpression (..)
74 , default_
72 , default_
76 , smallserial
74 , smallserial
@@ -122,7 +120,7 @@ CREATE statements
122-- >>> :set -XOverloadedLabels
120-- >>> :set -XOverloadedLabels
124-- renderDefinition $
122-- renderDefinition $
125−-- createTable #tab ((int & null') `As` #a :* (real & null') `As` #b :* Nil) Nil
123+-- createTable #tab ((int & null_) `As` #a :* (real & null_) `As` #b :* Nil) Nil
127-- "CREATE TABLE \"tab\" (\"a\" int NULL, \"b\" real NULL);"
125-- "CREATE TABLE \"tab\" (\"a\" int NULL, \"b\" real NULL);"
128createTable
126createTable
@@ -149,7 +147,7 @@ createTable tab columns constraints = UnsafeDefinition $
149-- >>> type Schema = '["tab" ::: 'Table Table]
147-- >>> type Schema = '["tab" ::: 'Table Table]
151-- renderDefinition
149-- renderDefinition
152−-- (createTableIfNotExists #tab ((int & null') `As` #a :* (real & null') `As` #b :* Nil) Nil :: Definition Schema Schema)
150+-- (createTableIfNotExists #tab ((int & null_) `As` #a :* (real & null_) `As` #b :* Nil) Nil :: Definition Schema Schema)
154-- "CREATE TABLE IF NOT EXISTS \"tab\" (\"a\" int NULL, \"b\" real NULL);"
152-- "CREATE TABLE IF NOT EXISTS \"tab\" (\"a\" int NULL, \"b\" real NULL);"
155createTableIfNotExists
153createTableIfNotExists
@@ -262,8 +260,8 @@ check _cols condition = UnsafeTableConstraintExpression $
263-- definition :: Definition '[] Schema
261-- definition :: Definition '[] Schema
264-- definition = createTable #tab
262-- definition = createTable #tab
265−-- ( (int & null') `As` #a :*
263+-- ( (int & null_) `As` #a :*
266−-- (int & null') `As` #b :* Nil )
264+-- (int & null_) `As` #b :* Nil )
267-- ( unique (#a :* #b :* Nil) `As` #uq_a_b :* Nil )
265-- ( unique (#a :* #b :* Nil) `As` #uq_a_b :* Nil )
@@ -343,7 +341,7 @@ primaryKey columns = UnsafeTableConstraintExpression $
343-- createTable #emails
341-- createTable #emails
344-- ( serial `As` #id :*
342-- ( serial `As` #id :*
345-- (int & notNull) `As` #user_id :*
343-- (int & notNull) `As` #user_id :*
346−-- (text & null') `As` #email :* Nil )
344+-- (text & null_) `As` #email :* Nil )
347-- ( primaryKey #id `As` #pk_emails :*
345-- ( primaryKey #id `As` #pk_emails :*
348-- foreignKey #user_id #users #id
346-- foreignKey #user_id #users #id
349-- OnDeleteCascade OnUpdateCascade `As` #fk_user_id :* Nil )
347-- OnDeleteCascade OnUpdateCascade `As` #fk_user_id :* Nil )
@@ -373,7 +371,7 @@ primaryKey columns = UnsafeTableConstraintExpression $
373-- createTable #employees
371-- createTable #employees
374-- ( serial `As` #id :*
372-- ( serial `As` #id :*
375-- (text & notNull) `As` #name :*
373-- (text & notNull) `As` #name :*
376−-- (integer & null') `As` #employer_id :* Nil )
374+-- (integer & null_) `As` #employer_id :* Nil )
377-- ( primaryKey #id `As` #employees_pk :*
375-- ( primaryKey #id `As` #employees_pk :*
378-- foreignKey #employer_id #employees #id
376-- foreignKey #employer_id #employees #id
379-- OnDeleteCascade OnUpdateCascade `As` #employees_employer_fk :* Nil )
377-- OnDeleteCascade OnUpdateCascade `As` #employees_employer_fk :* Nil )
@@ -575,7 +573,7 @@ class AddColumn ty where
575 -- '["tab" ::: 'Table ('[] :=>
573 -- '["tab" ::: 'Table ('[] :=>
576 -- '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
574 -- '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
577 -- , "col2" ::: 'Def :=> 'Null 'PGtext ])]
575 -- , "col2" ::: 'Def :=> 'Null 'PGtext ])]
578− -- definition = alterTable #tab (addColumn #col2 (text & null' & default_ "foo"))
576+ -- definition = alterTable #tab (addColumn #col2 (text & null_ & default_ "foo"))
579 -- in renderDefinition definition
577 -- in renderDefinition definition
581 -- "ALTER TABLE \"tab\" ADD COLUMN \"col2\" text NULL DEFAULT E'foo';"
579 -- "ALTER TABLE \"tab\" ADD COLUMN \"col2\" text NULL DEFAULT E'foo';"
@@ -587,7 +585,7 @@ class AddColumn ty where
587 -- '["tab" ::: 'Table ('[] :=>
585 -- '["tab" ::: 'Table ('[] :=>
588 -- '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
586 -- '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
589 -- , "col2" ::: 'NoDef :=> 'Null 'PGtext ])]
587 -- , "col2" ::: 'NoDef :=> 'Null 'PGtext ])]
590− -- definition = alterTable #tab (addColumn #col2 (text & null'))
588+ -- definition = alterTable #tab (addColumn #col2 (text & null_))
591 -- in renderDefinition definition
589 -- in renderDefinition definition
593 -- "ALTER TABLE \"tab\" ADD COLUMN \"col2\" text NULL;"
591 -- "ALTER TABLE \"tab\" ADD COLUMN \"col2\" text NULL;"
@@ -826,17 +824,18 @@ instance (Has alias schema ('Typedef ty))
826 => IsLabel alias (ColumnTypeExpression schema ('NoDef :=> 'NotNull ty)) where
824 => IsLabel alias (ColumnTypeExpression schema ('NoDef :=> 'NotNull ty)) where
827 fromLabel = UnsafeColumnTypeExpression (renderAlias (fromLabel @alias))
825 fromLabel = UnsafeColumnTypeExpression (renderAlias (fromLabel @alias))
829−null'
827+instance HasNull
830− :: TypeExpression ty
828+ ( TypeExpression ty
831− -> ColumnTypeExpression schema ('NoDef :=> 'Null ty)
829+ -> ColumnTypeExpression schema ('NoDef :=> 'Null ty) ) where
832−null' ty = UnsafeColumnTypeExpression $ renderTypeExpression ty <+> "NULL"
830+ null_ ty = UnsafeColumnTypeExpression $ renderTypeExpression ty <+> "NULL"
835+ ColumnTypeExpression schema (def :=> 'NotNull ty) ) where
834−-- | used in `createTable` commands as a column constraint to ensure
836+ -- | used in `createTable` commands as a column constraint to ensure
835−-- @NULL@ is not present
837+ -- @NULL@ is not present
837− :: TypeExpression ty
838− -> ColumnTypeExpression schema (def :=> 'NotNull ty)
839−notNull ty = UnsafeColumnTypeExpression $ renderTypeExpression ty <+> "NOT NULL"
838+ notNull ty = UnsafeColumnTypeExpression $ renderTypeExpression ty <+> "NOT NULL"
841-- | used in `createTable` commands as a column constraint to give a default
840-- | used in `createTable` commands as a column constraint to give a default