on dev help sign in
Merge pull request #143 from league/domain-alias

Fix alias type variable in createDomain

commit5657b81dd2b0c5256aadaa9b447c1fe3d2ebfc6b authorEitan Chatav <eitan.chatav@gmail.com> dateWed 21 Aug 2019, 09:34 (7 years ago) parent83c711a2de32fb
2 files changed+5−2
squeal-postgresql/exe/Example.hs+4−1 squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+1−1
squeal-postgresql/exe/Example.hs+4−1
@@ -38,6 +38,7 @@ type Schema =
3838 , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4
3939 , "email" ::: 'NoDef :=> 'Null 'PGtext
4040 ])
41+ , "positive" ::: 'Typedef 'PGfloat4
4142 ]
4243
4344type Schemas = Public Schema
@@ -57,9 +58,11 @@ setup =
5758 ( primaryKey #id `as` #pk_emails :*
5859 foreignKey #user_id #users #id
5960 OnDeleteCascade OnUpdateCascade `as` #fk_user_id )
61+ >>>
62+ createDomain #positive real (#value .> 0 .&& (#value & isNotNull))
6063
6164teardown :: Definition Schemas (Public '[])
62−teardown = dropTable #emails >>> dropTable #users
65+teardown = dropType #positive >>> dropTable #emails >>> dropTable #users
6366
6467insertUser :: Manipulation_ Schemas (Text, VarArray (Vector (Maybe Int16))) (Only Int32)
6568insertUser = insertInto #users
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+1−1
@@ -1034,7 +1034,7 @@ createDomain
10341034 => QualifiedAlias sch dom
10351035 -> (forall nullity. TypeExpression schemas (nullity ty))
10361036 -> (forall tab. Condition '[] '[] 'Ungrouped schemas '[] '[tab ::: '["value" ::: 'Null ty]])
1037− -> Definition schemas (Alter sch (Create alias ('Typedef ty) schema) schemas)
1037+ -> Definition schemas (Alter sch (Create dom ('Typedef ty) schema) schemas)
10381038createDomain dom ty condition =
10391039 UnsafeDefinition $ "CREATE DOMAIN" <+> renderSQL dom
10401040 <+> "AS" <+> renderTypeExpression ty