@@ -44,18 +44,18 @@ type Schema =
44setup :: Definition '[] Schema
44setup :: Definition '[] Schema
46 createTable #users
46 createTable #users
47− ( serial `As` #id :*
47+ ( serial `as` #id :*
48− (text & notNullable) `As` #name :*
48+ (text & notNullable) `as` #name :*
49− (vararray int2 & notNullable) `As` #vec :* Nil )
49+ (vararray int2 & notNullable) `as` #vec )
50− ( primaryKey #id `As` #pk_users :* Nil )
50+ ( primaryKey #id `as` #pk_users )
52 createTable #emails
52 createTable #emails
53− ( serial `As` #id :*
53+ ( serial `as` #id :*
54− (int & notNullable) `As` #user_id :*
54+ (int & notNullable) `as` #user_id :*
55− (text & nullable) `As` #email :* Nil )
55+ (text & nullable) `as` #email )
56− ( primaryKey #id `As` #pk_emails :*
56+ ( primaryKey #id `as` #pk_emails :*
57 foreignKey #user_id #users #id
57 foreignKey #user_id #users #id
58− OnDeleteCascade OnUpdateCascade `As` #fk_user_id :* Nil )
58+ OnDeleteCascade OnUpdateCascade `as` #fk_user_id )
60teardown :: Definition Schema '[]
60teardown :: Definition Schema '[]
61teardown = dropTable #emails >>> dropTable #users
61teardown = dropTable #emails >>> dropTable #users
@@ -63,14 +63,14 @@ teardown = dropTable #emails >>> dropTable #users
63insertUser :: Manipulation Schema '[ 'NotNull 'PGtext, 'NotNull ('PGvararray 'PGint2)]
63insertUser :: Manipulation Schema '[ 'NotNull 'PGtext, 'NotNull ('PGvararray 'PGint2)]
64 '[ "fromOnly" ::: 'NotNull 'PGint4 ]
64 '[ "fromOnly" ::: 'NotNull 'PGint4 ]
65insertUser = insertRows #users
65insertUser = insertRows #users
66− (Default `As` #id :* Set (param @1) `As` #name :* Set (param @2) `As` #vec :* Nil) []
66+ (Default `as` #id :* Set (param @1) `as` #name :* Set (param @2) `as` #vec) []
67− OnConflictDoNothing (Returning (#id `As` #fromOnly :* Nil))
67+ OnConflictDoNothing (Returning (#id `as` #fromOnly))
69insertEmail :: Manipulation Schema '[ 'NotNull 'PGint4, 'Null 'PGtext] '[]
69insertEmail :: Manipulation Schema '[ 'NotNull 'PGint4, 'Null 'PGtext] '[]
70insertEmail = insertRows #emails
70insertEmail = insertRows #emails
71− ( Default `As` #id :*
71+ ( Default `as` #id :*
72− Set (param @1) `As` #user_id :*
72+ Set (param @1) `as` #user_id :*
73− Set (param @2) `As` #email :* Nil ) []
73+ Set (param @2) `as` #email ) []
74 OnConflictDoNothing (Returning Nil)
74 OnConflictDoNothing (Returning Nil)
76getUsers :: Query Schema '[]
76getUsers :: Query Schema '[]
@@ -78,9 +78,9 @@ getUsers :: Query Schema '[]
78 , "userEmail" ::: 'Null 'PGtext
78 , "userEmail" ::: 'Null 'PGtext
79 , "userVec" ::: 'NotNull ('PGvararray 'PGint2)]
79 , "userVec" ::: 'NotNull ('PGvararray 'PGint2)]
80getUsers = select
80getUsers = select
81− (#u ! #name `As` #userName :* #e ! #email `As` #userEmail :* #u ! #vec `As` #userVec :* Nil)
81+ (#u ! #name `as` #userName :* #e ! #email `as` #userEmail :* #u ! #vec `as` #userVec)
82− ( from (table (#users `As` #u)
82+ ( from (table (#users `as` #u)
83− & innerJoin (table (#emails `As` #e))
83+ & innerJoin (table (#emails `as` #e))
84 (#u ! #id .== #e ! #user_id)) )
84 (#u ! #id .== #e ! #user_id)) )
86data User = User { userName :: Text, userEmail :: Maybe Text, userVec :: Vector (Maybe Int16) }
86data User = User { userName :: Text, userEmail :: Maybe Text, userVec :: Vector (Maybe Int16) }