on dev help sign in
Merge pull request #39 from echatav/squeal
ea3d964Eitan Chatav
squeal-postgresql/exe/Example.hs+1−1
@@ -62,7 +62,7 @@ main = do
62 ( Values
62 ( Values
63 (param (Proxy @1) `As` #col1 :* param (Proxy @2) `As` #col2 :* Nil)
63 (param (Proxy @1) `As` #col1 :* param (Proxy @2) `As` #col2 :* Nil)
64 [param (Proxy @3) `As` #col1 :* param (Proxy @4) `As` #col2 :* Nil]
64 [param (Proxy @3) `As` #col1 :* param (Proxy @4) `As` #col2 :* Nil]
65− ) Conflict ReturningNil
65+ ) Conflict (Returning Nil)
66 liftBase $ Char8.putStrLn "manipulating"
66 liftBase $ Char8.putStrLn "manipulating"
67 _ <- pqExecParams manipulation (1::Int32,2::Int32,3::Int32,4::Int32)
67 _ <- pqExecParams manipulation (1::Int32,2::Int32,3::Int32,4::Int32)
68 liftBase $ Char8.putStrLn "querying"
68 liftBase $ Char8.putStrLn "querying"
squeal-postgresql/src/Squeal/PostgreSQL/Statement.hs+8−8
@@ -900,9 +900,9 @@ SELECT statements
900
900
901select
901select
902 :: SListI columns
902 :: SListI columns
903− => NP (Aliased (Expression params tables grouping)) columns
903+ => NP (Aliased (Expression params tables grouping)) (column ': columns)
904 -> TableExpression params schema tables grouping
904 -> TableExpression params schema tables grouping
905− -> Query schema params columns
905+ -> Query schema params (column ': columns)
906select list tabs = UnsafeQuery $
906select list tabs = UnsafeQuery $
907 "SELECT"
907 "SELECT"
908 <+> renderCommaSeparated (renderAliased renderExpression) list
908 <+> renderCommaSeparated (renderAliased renderExpression) list
@@ -936,9 +936,9 @@ CREATE statements
936createTable
936createTable
937 :: (KnownSymbol table, SListI columns)
937 :: (KnownSymbol table, SListI columns)
938 => Alias table
938 => Alias table
939− -> NP (Aliased TypeExpression) columns
939+ -> NP (Aliased TypeExpression) (column ': columns)
940− -> [TableConstraint schema columns]
940+ -> [TableConstraint schema (column ': columns)]
941− -> Definition schema (Create table columns schema)
941+ -> Definition schema (Create table (column ': columns) schema)
942createTable table columns constraints = UnsafeDefinition $
942createTable table columns constraints = UnsafeDefinition $
943 "CREATE TABLE" <+> renderAlias table
943 "CREATE TABLE" <+> renderAlias table
944 <+> parenthesized
944 <+> parenthesized
@@ -1167,10 +1167,10 @@ data ReturningClause
1167 (columns :: [(Symbol,ColumnType)])
1167 (columns :: [(Symbol,ColumnType)])
1168 (results :: [(Symbol,ColumnType)])
1168 (results :: [(Symbol,ColumnType)])
1169 where
1169 where
1170− ReturningNil :: ReturningClause params columns '[]
1171 ReturningStar :: ReturningClause params columns columns
1170 ReturningStar :: ReturningClause params columns columns
1172 Returning
1171 Returning
1173− :: NP (Aliased (Expression params '[table ::: columns] 'Ungrouped)) results
1172+ :: NP (Aliased (Expression params '[table ::: columns] 'Ungrouped))
1173+ results
1174 -> ReturningClause params columns results
1174 -> ReturningClause params columns results
1175
1175
1176renderReturningClause
1176renderReturningClause
@@ -1178,8 +1178,8 @@ renderReturningClause
1178 => ReturningClause params columns results
1178 => ReturningClause params columns results
1179 -> ByteString
1179 -> ByteString
1180renderReturningClause = \case
1180renderReturningClause = \case
1181− ReturningNil -> ";"
1182 ReturningStar -> " RETURNING *;"
1181 ReturningStar -> " RETURNING *;"
1182+ Returning Nil -> ";"
1183 Returning results -> " RETURNING"
1183 Returning results -> " RETURNING"
1184 <+> renderCommaSeparated (renderAliased renderExpression) results <> ";"
1184 <+> renderCommaSeparated (renderAliased renderExpression) results <> ";"
1185
1185
squeal-postgresql/test/Squeal/PostgreSQL/StatementSpec.hs+4−4
@@ -102,7 +102,7 @@ spec = do
102 statement :: Manipulation Tables '[] '[]
102 statement :: Manipulation Tables '[] '[]
103 statement =
103 statement =
104 insertInto #table1 (Values (2 `As` #col1 :* 4 `As` #col2 :* Nil) [])
104 insertInto #table1 (Values (2 `As` #col1 :* 4 `As` #col2 :* Nil) [])
105− Conflict ReturningNil
105+ Conflict (Returning Nil)
106 statement `manipulationRenders`
106 statement `manipulationRenders`
107 "INSERT INTO table1 (col1, col2) VALUES (2, 4);"
107 "INSERT INTO table1 (col1, col2) VALUES (2, 4);"
108 it "correctly renders returning INSERTs" $ do
108 it "correctly renders returning INSERTs" $ do
@@ -120,7 +120,7 @@ spec = do
120 statement :: Manipulation Tables '[] '[]
120 statement :: Manipulation Tables '[] '[]
121 statement =
121 statement =
122 update #table1 (Set 2 `As` #col1 :* Same `As` #col2 :* Nil)
122 update #table1 (Set 2 `As` #col1 :* Same `As` #col2 :* Nil)
123− (#col1 /=* #col2) ReturningNil
123+ (#col1 /=* #col2) (Returning Nil)
124 statement `manipulationRenders`
124 statement `manipulationRenders`
125 "UPDATE table1 SET col1 = 2\
125 "UPDATE table1 SET col1 = 2\
126 \ WHERE (col1 <> col2);"
126 \ WHERE (col1 <> col2);"
@@ -142,7 +142,7 @@ spec = do
142 insertInto #table1 (Values (2 `As` #col1 :* 4 `As` #col2 :* Nil) [])
142 insertInto #table1 (Values (2 `As` #col1 :* 4 `As` #col2 :* Nil) [])
143 (OnConflictDoUpdate
143 (OnConflictDoUpdate
144 (Set 2 `As` #col1 :* Same `As` #col2 :* Nil) (#col1 /=* #col2))
144 (Set 2 `As` #col1 :* Same `As` #col2 :* Nil) (#col1 /=* #col2))
145− ReturningNil
145+ (Returning Nil)
146 statement `manipulationRenders`
146 statement `manipulationRenders`
147 "INSERT INTO table1 (col1, col2) VALUES (2, 4)\
147 "INSERT INTO table1 (col1, col2) VALUES (2, 4)\
148 \ ON CONFLICT DO UPDATE\
148 \ ON CONFLICT DO UPDATE\
@@ -173,7 +173,7 @@ spec = do
173 statement :: Manipulation StudentsTable '[] '[]
173 statement :: Manipulation StudentsTable '[] '[]
174 statement = insertInto #students
174 statement = insertInto #students
175 (Values ("Robert'); DROP TABLE students;" `As` #name :* Nil) [])
175 (Values ("Robert'); DROP TABLE students;" `As` #name :* Nil) [])
176− Conflict ReturningNil
176+ Conflict (Returning Nil)
177 statement `manipulationRenders`
177 statement `manipulationRenders`
178 "INSERT INTO students (name) VALUES (E'Robert''); DROP TABLE students;');"
178 "INSERT INTO students (name) VALUES (E'Robert''); DROP TABLE students;');"
179 describe "JOINs" $ do
179 describe "JOINs" $ do