@@ -195,7 +195,7 @@ class KnownNat n => HasParameter
195 -- >>> printSQL expr
195 -- >>> printSQL expr
196 -- ($1 :: int4)
196 -- ($1 :: int4)
197 parameter
197 parameter
198− :: TypeExpression schema (PGTypeOf ty)
198+ :: TypeExpression schema ty
199 -> Expression schema relations grouping params ty
199 -> Expression schema relations grouping params ty
200 parameter ty = UnsafeExpression $ parenthesized $
200 parameter ty = UnsafeExpression $ parenthesized $
201 "$" <> renderNat (Proxy @n) <+> "::"
201 "$" <> renderNat (Proxy @n) <+> "::"
@@ -211,9 +211,9 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) schema params ty)
211-- >>> printSQL expr
211-- >>> printSQL expr
212-- ($1 :: int4)
212-- ($1 :: int4)
214− :: forall n schema params relations grouping ty
214+ :: forall n schema params relations grouping nullity ty
215− . (PGTyped schema (PGTypeOf ty), HasParameter n schema params ty)
215+ . (PGTyped schema ty, HasParameter n schema params (nullity ty))
216− => Expression schema relations grouping params ty -- ^ param
216+ => Expression schema relations grouping params (nullity ty) -- ^ param
217param = parameter @n pgtype
217param = parameter @n pgtype
219instance (HasUnique relation relations columns, Has column columns ty)
219instance (HasUnique relation relations columns, Has column columns ty)
@@ -400,16 +400,16 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
400-- >>> printSQL i
400-- >>> printSQL i
401-- ROW(0, 1)
401-- ROW(0, 1)
403− :: SListI (Nulls fields)
403+ :: SListI fields
404− => NP (Aliased (Expression schema relations grouping params)) (Nulls fields)
404+ => NP (Aliased (Expression schema relations grouping params)) fields
405 -- ^ zero or more expressions for the row field values
405 -- ^ zero or more expressions for the row field values
406 -> Expression schema relations grouping params (nullity ('PGcomposite fields))
406 -> Expression schema relations grouping params (nullity ('PGcomposite fields))
407row exprs = UnsafeExpression $ "ROW" <> parenthesized
407row exprs = UnsafeExpression $ "ROW" <> parenthesized
408 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
408 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
410instance Has field fields ty => IsLabel field
410instance Has field fields ty => IsLabel field
411− ( Expression schema relation grouping params (nullity ('PGcomposite fields))
411+ ( Expression schema relation grouping params ('NotNull ('PGcomposite fields))
412− -> Expression schema relation grouping params ('Null ty) ) where
412+ -> Expression schema relation grouping params ty ) where
413 fromLabel expr = UnsafeExpression $
413 fromLabel expr = UnsafeExpression $
414 parenthesized (renderExpression expr) <> "." <>
414 parenthesized (renderExpression expr) <> "." <>
415 fromString (symbolVal (Proxy @field))
415 fromString (symbolVal (Proxy @field))
@@ -1117,96 +1117,96 @@ type expressions
1117-----------------------------------------}
1117-----------------------------------------}
1119-- | `TypeExpression`s are used in `cast`s and `createTable` commands.
1119-- | `TypeExpression`s are used in `cast`s and `createTable` commands.
1120−newtype TypeExpression (schema :: SchemaType) (ty :: PGType)
1120+newtype TypeExpression (schema :: SchemaType) (ty :: NullityType)
1121 = UnsafeTypeExpression { renderTypeExpression :: ByteString }
1121 = UnsafeTypeExpression { renderTypeExpression :: ByteString }
1122 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1122 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1124instance (Has alias schema ('Typedef ty))
1124instance (Has alias schema ('Typedef ty))
1125− => IsLabel alias (TypeExpression schema ty) where
1125+ => IsLabel alias (TypeExpression schema (nullity ty)) where
1126 fromLabel = UnsafeTypeExpression (renderAlias (fromLabel @alias))
1126 fromLabel = UnsafeTypeExpression (renderAlias (fromLabel @alias))
1128-- | logical Boolean (true/false)
1128-- | logical Boolean (true/false)
1129−bool :: TypeExpression schema 'PGbool
1129+bool :: TypeExpression schema (nullity 'PGbool)
1130bool = UnsafeTypeExpression "bool"
1130bool = UnsafeTypeExpression "bool"
1131-- | signed two-byte integer
1131-- | signed two-byte integer
1132−int2, smallint :: TypeExpression schema 'PGint2
1132+int2, smallint :: TypeExpression schema (nullity 'PGint2)
1133int2 = UnsafeTypeExpression "int2"
1133int2 = UnsafeTypeExpression "int2"
1134smallint = UnsafeTypeExpression "smallint"
1134smallint = UnsafeTypeExpression "smallint"
1135-- | signed four-byte integer
1135-- | signed four-byte integer
1136−int4, int, integer :: TypeExpression schema 'PGint4
1136+int4, int, integer :: TypeExpression schema (nullity 'PGint4)
1137int4 = UnsafeTypeExpression "int4"
1137int4 = UnsafeTypeExpression "int4"
1138int = UnsafeTypeExpression "int"
1138int = UnsafeTypeExpression "int"
1139integer = UnsafeTypeExpression "integer"
1139integer = UnsafeTypeExpression "integer"
1140-- | signed eight-byte integer
1140-- | signed eight-byte integer
1141−int8, bigint :: TypeExpression schema 'PGint8
1141+int8, bigint :: TypeExpression schema (nullity 'PGint8)
1142int8 = UnsafeTypeExpression "int8"
1142int8 = UnsafeTypeExpression "int8"
1143bigint = UnsafeTypeExpression "bigint"
1143bigint = UnsafeTypeExpression "bigint"
1144-- | arbitrary precision numeric type
1144-- | arbitrary precision numeric type
1145−numeric :: TypeExpression schema 'PGnumeric
1145+numeric :: TypeExpression schema (nullity 'PGnumeric)
1146numeric = UnsafeTypeExpression "numeric"
1146numeric = UnsafeTypeExpression "numeric"
1147-- | single precision floating-point number (4 bytes)
1147-- | single precision floating-point number (4 bytes)
1148−float4, real :: TypeExpression schema 'PGfloat4
1148+float4, real :: TypeExpression schema (nullity 'PGfloat4)
1149float4 = UnsafeTypeExpression "float4"
1149float4 = UnsafeTypeExpression "float4"
1150real = UnsafeTypeExpression "real"
1150real = UnsafeTypeExpression "real"
1151-- | double precision floating-point number (8 bytes)
1151-- | double precision floating-point number (8 bytes)
1152−float8, doublePrecision :: TypeExpression schema 'PGfloat8
1152+float8, doublePrecision :: TypeExpression schema (nullity 'PGfloat8)
1153float8 = UnsafeTypeExpression "float8"
1153float8 = UnsafeTypeExpression "float8"
1154doublePrecision = UnsafeTypeExpression "double precision"
1154doublePrecision = UnsafeTypeExpression "double precision"
1155-- | variable-length character string
1155-- | variable-length character string
1156−text :: TypeExpression schema 'PGtext
1156+text :: TypeExpression schema (nullity 'PGtext)
1157text = UnsafeTypeExpression "text"
1157text = UnsafeTypeExpression "text"
1158-- | fixed-length character string
1158-- | fixed-length character string
1159char, character
1159char, character
1160 :: (KnownNat n, 1 <= n)
1160 :: (KnownNat n, 1 <= n)
1161 => proxy n
1161 => proxy n
1162− -> TypeExpression schema ('PGchar n)
1162+ -> TypeExpression schema (nullity ('PGchar n))
1163char p = UnsafeTypeExpression $ "char(" <> renderNat p <> ")"
1163char p = UnsafeTypeExpression $ "char(" <> renderNat p <> ")"
1164character p = UnsafeTypeExpression $ "character(" <> renderNat p <> ")"
1164character p = UnsafeTypeExpression $ "character(" <> renderNat p <> ")"
1165-- | variable-length character string
1165-- | variable-length character string
1166varchar, characterVarying
1166varchar, characterVarying
1167 :: (KnownNat n, 1 <= n)
1167 :: (KnownNat n, 1 <= n)
1168 => proxy n
1168 => proxy n
1169− -> TypeExpression schema ('PGvarchar n)
1169+ -> TypeExpression schema (nullity ('PGvarchar n))
1170varchar p = UnsafeTypeExpression $ "varchar(" <> renderNat p <> ")"
1170varchar p = UnsafeTypeExpression $ "varchar(" <> renderNat p <> ")"
1171characterVarying p = UnsafeTypeExpression $
1171characterVarying p = UnsafeTypeExpression $
1172 "character varying(" <> renderNat p <> ")"
1172 "character varying(" <> renderNat p <> ")"
1173-- | binary data ("byte array")
1173-- | binary data ("byte array")
1174−bytea :: TypeExpression schema 'PGbytea
1174+bytea :: TypeExpression schema (nullity 'PGbytea)
1175bytea = UnsafeTypeExpression "bytea"
1175bytea = UnsafeTypeExpression "bytea"
1176-- | date and time (no time zone)
1176-- | date and time (no time zone)
1177−timestamp :: TypeExpression schema 'PGtimestamp
1177+timestamp :: TypeExpression schema (nullity 'PGtimestamp)
1178timestamp = UnsafeTypeExpression "timestamp"
1178timestamp = UnsafeTypeExpression "timestamp"
1179-- | date and time, including time zone
1179-- | date and time, including time zone
1180−timestampWithTimeZone :: TypeExpression schema 'PGtimestamptz
1180+timestampWithTimeZone :: TypeExpression schema (nullity 'PGtimestamptz)
1181timestampWithTimeZone = UnsafeTypeExpression "timestamp with time zone"
1181timestampWithTimeZone = UnsafeTypeExpression "timestamp with time zone"
1182-- | calendar date (year, month, day)
1182-- | calendar date (year, month, day)
1183−date :: TypeExpression schema 'PGdate
1183+date :: TypeExpression schema (nullity 'PGdate)
1184date = UnsafeTypeExpression "date"
1184date = UnsafeTypeExpression "date"
1185-- | time of day (no time zone)
1185-- | time of day (no time zone)
1186−time :: TypeExpression schema 'PGtime
1186+time :: TypeExpression schema (nullity 'PGtime)
1187time = UnsafeTypeExpression "time"
1187time = UnsafeTypeExpression "time"
1188-- | time of day, including time zone
1188-- | time of day, including time zone
1189−timeWithTimeZone :: TypeExpression schema 'PGtimetz
1189+timeWithTimeZone :: TypeExpression schema (nullity 'PGtimetz)
1190timeWithTimeZone = UnsafeTypeExpression "time with time zone"
1190timeWithTimeZone = UnsafeTypeExpression "time with time zone"
1191-- | time span
1191-- | time span
1192−interval :: TypeExpression schema 'PGinterval
1192+interval :: TypeExpression schema (nullity 'PGinterval)
1193interval = UnsafeTypeExpression "interval"
1193interval = UnsafeTypeExpression "interval"
1194-- | universally unique identifier
1194-- | universally unique identifier
1195−uuid :: TypeExpression schema 'PGuuid
1195+uuid :: TypeExpression schema (nullity 'PGuuid)
1196uuid = UnsafeTypeExpression "uuid"
1196uuid = UnsafeTypeExpression "uuid"
1197-- | IPv4 or IPv6 host address
1197-- | IPv4 or IPv6 host address
1198−inet :: TypeExpression schema 'PGinet
1198+inet :: TypeExpression schema (nullity 'PGinet)
1199inet = UnsafeTypeExpression "inet"
1199inet = UnsafeTypeExpression "inet"
1200-- | textual JSON data
1200-- | textual JSON data
1201−json :: TypeExpression schema 'PGjson
1201+json :: TypeExpression schema (nullity 'PGjson)
1202json = UnsafeTypeExpression "json"
1202json = UnsafeTypeExpression "json"
1203-- | binary JSON data, decomposed
1203-- | binary JSON data, decomposed
1204−jsonb :: TypeExpression schema 'PGjsonb
1204+jsonb :: TypeExpression schema (nullity 'PGjsonb)
1205jsonb = UnsafeTypeExpression "jsonb"
1205jsonb = UnsafeTypeExpression "jsonb"
1206-- | variable length array
1206-- | variable length array
1208 :: TypeExpression schema pg
1208 :: TypeExpression schema pg
1209− -> TypeExpression schema ('PGvararray (nullity pg))
1209+ -> TypeExpression schema (nullity ('PGvararray pg))
1210vararray ty = UnsafeTypeExpression $ renderTypeExpression ty <> "[]"
1210vararray ty = UnsafeTypeExpression $ renderTypeExpression ty <> "[]"
1211-- | fixed length array
1211-- | fixed length array
@@ -1215,12 +1215,12 @@ vararray ty = UnsafeTypeExpression $ renderTypeExpression ty <> "[]"
1216 :: forall n schema nullity pg. KnownNat n
1216 :: forall n schema nullity pg. KnownNat n
1217 => TypeExpression schema pg
1217 => TypeExpression schema pg
1218− -> TypeExpression schema ('PGfixarray n (nullity pg))
1218+ -> TypeExpression schema (nullity ('PGfixarray n pg))
1219fixarray ty = UnsafeTypeExpression $
1219fixarray ty = UnsafeTypeExpression $
1220 renderTypeExpression ty <> "[" <> renderNat (Proxy @n) <> "]"
1220 renderTypeExpression ty <> "[" <> renderNat (Proxy @n) <> "]"
1222-- | `pgtype` is a demoted version of a `PGType`
1222-- | `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)
1224instance PGTyped schema 'PGbool where pgtype = bool
1224instance PGTyped schema 'PGbool where pgtype = bool
1225instance PGTyped schema 'PGint2 where pgtype = int2
1225instance PGTyped schema 'PGint2 where pgtype = int2
1226instance PGTyped schema 'PGint4 where pgtype = int4
1226instance PGTyped schema 'PGint4 where pgtype = int4