@@ -129,8 +129,17 @@ CREATE statements
130>>> :set -XOverloadedLabels
130>>> :set -XOverloadedLabels
132−printSQL $
132+type Table = '[] :=>
133+ '[ "a" ::: 'NoDef :=> 'Null 'PGint4
134+ , "b" ::: 'NoDef :=> 'Null 'PGfloat4 ]
139+ setup :: Definition '[] '["tab" ::: 'Table Table]
133− createTable #tab ((int & nullable) `As` #a :* (real & nullable) `As` #b :* Nil) Nil
140+ setup = createTable #tab
141+ (nullable int `as` #a :* nullable real `as` #b) Nil
135CREATE TABLE "tab" ("a" int NULL, "b" real NULL);
144CREATE TABLE "tab" ("a" int NULL, "b" real NULL);
@@ -155,12 +164,19 @@ Instead, the schema already has the table so if the table did not yet exist, the
155the `Category` of `Definition`s.
164the `Category` of `Definition`s.
157>>> :set -XOverloadedLabels -XTypeApplications
166>>> :set -XOverloadedLabels -XTypeApplications
169+ '[ "a" ::: 'NoDef :=> 'Null 'PGint4
158−>>> type Table = '[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGfloat4]
170+ , "b" ::: 'NoDef :=> 'Null 'PGfloat4 ]
159>>> type Schema = '["tab" ::: 'Table Table]
173>>> type Schema = '["tab" ::: 'Table Table]
162 setup :: Definition Schema Schema
177 setup :: Definition Schema Schema
163− setup = createTableIfNotExists #tab ((int & nullable) `As` #a :* (real & nullable) `As` #b :* Nil) Nil
178+ setup = createTableIfNotExists #tab
179+ (nullable int `as` #a :* nullable real `as` #b) Nil
164in printSQL setup
180in printSQL setup
166CREATE TABLE IF NOT EXISTS "tab" ("a" int NULL, "b" real NULL);
182CREATE TABLE IF NOT EXISTS "tab" ("a" int NULL, "b" real NULL);
@@ -850,11 +866,20 @@ createTypeEnumFrom
850createTypeEnumFrom enum = createTypeEnum enum
866createTypeEnumFrom enum = createTypeEnum enum
851 (SOP.hpure label :: NP PGlabel (LabelsFrom hask))
867 (SOP.hpure label :: NP PGlabel (LabelsFrom hask))
853−-- | `createTypeComposite` creates a composite type. The composite type is
869+{- | `createTypeComposite` creates a composite type. The composite type is
854−-- specified by a list of attribute names and data types.
870+specified by a list of attribute names and data types.
856−-- >>> printSQL $ createTypeComposite #complex (float8 `As` #real :* float8 `As` #imaginary :* Nil)
872+>>> type PGcomplex = 'PGcomposite '["real" ::: 'PGfloat8, "imaginary" ::: 'PGfloat8]
876+ setup :: Definition '[] '["complex" ::: 'Typedef PGcomplex]
877+ setup = createTypeComposite #complex
878+ (float8 `as` #real :* float8 `as` #imaginary)
857−-- CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);
881+CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);
858createTypeComposite
883createTypeComposite
859 :: (KnownSymbol ty, SOP.SListI fields)
884 :: (KnownSymbol ty, SOP.SListI fields)
860 => Alias ty
885 => Alias ty