@@ -195,7 +195,7 @@ class KnownNat n => HasParameter
195195 -- >>> printSQL expr
196196 -- ($1 :: int4)
197197 parameter
198− :: TypeExpression schema (PGTypeOf ty)
198+ :: TypeExpression schema ty
199199 -> Expression schema relations grouping params ty
200200 parameter ty = UnsafeExpression $ parenthesized $
201201 "$" <> renderNat (Proxy @n) <+> "::"
@@ -211,9 +211,9 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) schema params ty)
211211-- >>> printSQL expr
212212-- ($1 :: int4)
213213param
214− :: forall n schema params relations grouping ty
215− . (PGTyped schema (PGTypeOf ty), HasParameter n schema params ty)
216− => Expression schema relations grouping params ty -- ^ param
214+ :: forall n schema params relations grouping nullity ty
215+ . (PGTyped schema ty, HasParameter n schema params (nullity ty))
216+ => Expression schema relations grouping params (nullity ty) -- ^ param
217217param = parameter @n pgtype
218218
219219instance (HasUnique relation relations columns, Has column columns ty)
@@ -400,16 +400,16 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
400400-- >>> printSQL i
401401-- ROW(0, 1)
402402row
403− :: SListI (Nulls fields)
404− => NP (Aliased (Expression schema relations grouping params)) (Nulls fields)
403+ :: SListI fields
404+ => NP (Aliased (Expression schema relations grouping params)) fields
405405 -- ^ zero or more expressions for the row field values
406406 -> Expression schema relations grouping params (nullity ('PGcomposite fields))
407407row exprs = UnsafeExpression $ "ROW" <> parenthesized
408408 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
409409
410410instance Has field fields ty => IsLabel field
411− ( Expression schema relation grouping params (nullity ('PGcomposite fields))
412− -> Expression schema relation grouping params ('Null ty) ) where
411+ ( Expression schema relation grouping params ('NotNull ('PGcomposite fields))
412+ -> Expression schema relation grouping params ty ) where
413413 fromLabel expr = UnsafeExpression $
414414 parenthesized (renderExpression expr) <> "." <>
415415 fromString (symbolVal (Proxy @field))
@@ -1117,96 +1117,96 @@ type expressions
11171117-----------------------------------------}
11181118
11191119-- | `TypeExpression`s are used in `cast`s and `createTable` commands.
1120−newtype TypeExpression (schema :: SchemaType) (ty :: PGType)
1120+newtype TypeExpression (schema :: SchemaType) (ty :: NullityType)
11211121 = UnsafeTypeExpression { renderTypeExpression :: ByteString }
11221122 deriving (GHC.Generic,Show,Eq,Ord,NFData)
11231123
11241124instance (Has alias schema ('Typedef ty))
1125− => IsLabel alias (TypeExpression schema ty) where
1125+ => IsLabel alias (TypeExpression schema (nullity ty)) where
11261126 fromLabel = UnsafeTypeExpression (renderAlias (fromLabel @alias))
11271127
11281128-- | logical Boolean (true/false)
1129−bool :: TypeExpression schema 'PGbool
1129+bool :: TypeExpression schema (nullity 'PGbool)
11301130bool = UnsafeTypeExpression "bool"
11311131-- | signed two-byte integer
1132−int2, smallint :: TypeExpression schema 'PGint2
1132+int2, smallint :: TypeExpression schema (nullity 'PGint2)
11331133int2 = UnsafeTypeExpression "int2"
11341134smallint = UnsafeTypeExpression "smallint"
11351135-- | signed four-byte integer
1136−int4, int, integer :: TypeExpression schema 'PGint4
1136+int4, int, integer :: TypeExpression schema (nullity 'PGint4)
11371137int4 = UnsafeTypeExpression "int4"
11381138int = UnsafeTypeExpression "int"
11391139integer = UnsafeTypeExpression "integer"
11401140-- | signed eight-byte integer
1141−int8, bigint :: TypeExpression schema 'PGint8
1141+int8, bigint :: TypeExpression schema (nullity 'PGint8)
11421142int8 = UnsafeTypeExpression "int8"
11431143bigint = UnsafeTypeExpression "bigint"
11441144-- | arbitrary precision numeric type
1145−numeric :: TypeExpression schema 'PGnumeric
1145+numeric :: TypeExpression schema (nullity 'PGnumeric)
11461146numeric = UnsafeTypeExpression "numeric"
11471147-- | single precision floating-point number (4 bytes)
1148−float4, real :: TypeExpression schema 'PGfloat4
1148+float4, real :: TypeExpression schema (nullity 'PGfloat4)
11491149float4 = UnsafeTypeExpression "float4"
11501150real = UnsafeTypeExpression "real"
11511151-- | double precision floating-point number (8 bytes)
1152−float8, doublePrecision :: TypeExpression schema 'PGfloat8
1152+float8, doublePrecision :: TypeExpression schema (nullity 'PGfloat8)
11531153float8 = UnsafeTypeExpression "float8"
11541154doublePrecision = UnsafeTypeExpression "double precision"
11551155-- | variable-length character string
1156−text :: TypeExpression schema 'PGtext
1156+text :: TypeExpression schema (nullity 'PGtext)
11571157text = UnsafeTypeExpression "text"
11581158-- | fixed-length character string
11591159char, character
11601160 :: (KnownNat n, 1 <= n)
11611161 => proxy n
1162− -> TypeExpression schema ('PGchar n)
1162+ -> TypeExpression schema (nullity ('PGchar n))
11631163char p = UnsafeTypeExpression $ "char(" <> renderNat p <> ")"
11641164character p = UnsafeTypeExpression $ "character(" <> renderNat p <> ")"
11651165-- | variable-length character string
11661166varchar, characterVarying
11671167 :: (KnownNat n, 1 <= n)
11681168 => proxy n
1169− -> TypeExpression schema ('PGvarchar n)
1169+ -> TypeExpression schema (nullity ('PGvarchar n))
11701170varchar p = UnsafeTypeExpression $ "varchar(" <> renderNat p <> ")"
11711171characterVarying p = UnsafeTypeExpression $
11721172 "character varying(" <> renderNat p <> ")"
11731173-- | binary data ("byte array")
1174−bytea :: TypeExpression schema 'PGbytea
1174+bytea :: TypeExpression schema (nullity 'PGbytea)
11751175bytea = UnsafeTypeExpression "bytea"
11761176-- | date and time (no time zone)
1177−timestamp :: TypeExpression schema 'PGtimestamp
1177+timestamp :: TypeExpression schema (nullity 'PGtimestamp)
11781178timestamp = UnsafeTypeExpression "timestamp"
11791179-- | date and time, including time zone
1180−timestampWithTimeZone :: TypeExpression schema 'PGtimestamptz
1180+timestampWithTimeZone :: TypeExpression schema (nullity 'PGtimestamptz)
11811181timestampWithTimeZone = UnsafeTypeExpression "timestamp with time zone"
11821182-- | calendar date (year, month, day)
1183−date :: TypeExpression schema 'PGdate
1183+date :: TypeExpression schema (nullity 'PGdate)
11841184date = UnsafeTypeExpression "date"
11851185-- | time of day (no time zone)
1186−time :: TypeExpression schema 'PGtime
1186+time :: TypeExpression schema (nullity 'PGtime)
11871187time = UnsafeTypeExpression "time"
11881188-- | time of day, including time zone
1189−timeWithTimeZone :: TypeExpression schema 'PGtimetz
1189+timeWithTimeZone :: TypeExpression schema (nullity 'PGtimetz)
11901190timeWithTimeZone = UnsafeTypeExpression "time with time zone"
11911191-- | time span
1192−interval :: TypeExpression schema 'PGinterval
1192+interval :: TypeExpression schema (nullity 'PGinterval)
11931193interval = UnsafeTypeExpression "interval"
11941194-- | universally unique identifier
1195−uuid :: TypeExpression schema 'PGuuid
1195+uuid :: TypeExpression schema (nullity 'PGuuid)
11961196uuid = UnsafeTypeExpression "uuid"
11971197-- | IPv4 or IPv6 host address
1198−inet :: TypeExpression schema 'PGinet
1198+inet :: TypeExpression schema (nullity 'PGinet)
11991199inet = UnsafeTypeExpression "inet"
12001200-- | textual JSON data
1201−json :: TypeExpression schema 'PGjson
1201+json :: TypeExpression schema (nullity 'PGjson)
12021202json = UnsafeTypeExpression "json"
12031203-- | binary JSON data, decomposed
1204−jsonb :: TypeExpression schema 'PGjsonb
1204+jsonb :: TypeExpression schema (nullity 'PGjsonb)
12051205jsonb = UnsafeTypeExpression "jsonb"
12061206-- | variable length array
12071207vararray
12081208 :: TypeExpression schema pg
1209− -> TypeExpression schema ('PGvararray (nullity pg))
1209+ -> TypeExpression schema (nullity ('PGvararray pg))
12101210vararray ty = UnsafeTypeExpression $ renderTypeExpression ty <> "[]"
12111211-- | fixed length array
12121212--
@@ -1215,12 +1215,12 @@ vararray ty = UnsafeTypeExpression $ renderTypeExpression ty <> "[]"
12151215fixarray
12161216 :: forall n schema nullity pg. KnownNat n
12171217 => TypeExpression schema pg
1218− -> TypeExpression schema ('PGfixarray n (nullity pg))
1218+ -> TypeExpression schema (nullity ('PGfixarray n pg))
12191219fixarray ty = UnsafeTypeExpression $
12201220 renderTypeExpression ty <> "[" <> renderNat (Proxy @n) <> "]"
12211221
12221222-- | `pgtype` is a demoted version of a `PGType`
1223−class PGTyped schema (ty :: PGType) where pgtype :: TypeExpression schema ty
1223+class PGTyped schema (ty :: PGType) where pgtype :: TypeExpression schema (nullity ty)
12241224instance PGTyped schema 'PGbool where pgtype = bool
12251225instance PGTyped schema 'PGint2 where pgtype = int2
12261226instance PGTyped schema 'PGint4 where pgtype = int4