@@ -45,6 +45,7 @@ module Squeal.PostgreSQL.Definition
45 , createTypeCompositeFrom
45 , createTypeCompositeFrom
46 , FieldTyped (..)
46 , FieldTyped (..)
47 , createDomain
47 , createDomain
48 , TableConstraintExpression (..)
49 , TableConstraintExpression (..)
@@ -1032,14 +1033,23 @@ CREATE DOMAIN "positive" AS real CHECK ((("value" > 0) AND "value" IS NOT NULL))
1032createDomain
1033createDomain
1033 :: (Has sch schemas schema, KnownSymbol dom)
1034 :: (Has sch schemas schema, KnownSymbol dom)
1034 => QualifiedAlias sch dom
1035 => QualifiedAlias sch dom
1035− -> (forall nullity. TypeExpression schemas (nullity ty))
1036+ -> (forall null. TypeExpression schemas (null ty))
1036 -> (forall tab. Condition '[] '[] 'Ungrouped schemas '[] '[tab ::: '["value" ::: 'Null ty]])
1037 -> (forall tab. Condition '[] '[] 'Ungrouped schemas '[] '[tab ::: '["value" ::: 'Null ty]])
1037− -> Definition schemas (Alter sch (Create alias ('Typedef ty) schema) schemas)
1038+ -> Definition schemas (Alter sch (Create dom ('Typedef ty) schema) schemas)
1038createDomain dom ty condition =
1039createDomain dom ty condition =
1039 UnsafeDefinition $ "CREATE DOMAIN" <+> renderSQL dom
1040 UnsafeDefinition $ "CREATE DOMAIN" <+> renderSQL dom
1040 <+> "AS" <+> renderTypeExpression ty
1041 <+> "AS" <+> renderTypeExpression ty
1041 <+> "CHECK" <+> parenthesized (renderSQL condition) <> ";"
1042 <+> "CHECK" <+> parenthesized (renderSQL condition) <> ";"
1045+ :: (Has sch schemas schema, KnownSymbol range)
1046+ => QualifiedAlias sch range
1047+ -> (forall null. TypeExpression schemas (null ty))
1048+ -> Definition schemas (Alter sch (Create range ('Typedef ('PGrange ty)) schema) schemas)
1049+createTypeRange range ty = UnsafeDefinition $
1050+ "CREATE" <+> "TYPE" <+> renderSQL range <+> "AS" <+> "RANGE" <+>
1051+ parenthesized ("subtype" <+> "=" <+> renderTypeExpression ty)
1043-- | Lift `PGTyped` to a field
1053-- | Lift `PGTyped` to a field
1044class FieldTyped schemas ty where
1054class FieldTyped schemas ty where
1045 fieldtype :: Aliased (TypeExpression schemas) ty
1055 fieldtype :: Aliased (TypeExpression schemas) ty