@@ -23,7 +23,7 @@ spec = do
23 query `shouldRenderAs` str = renderStatement query `shouldBe` str
23 query `shouldRenderAs` str = renderStatement query `shouldBe` str
24 it "correctly renders a simple SELECT query" $ do
24 it "correctly renders a simple SELECT query" $ do
26− statement :: Statement '[] Tables Tables SumAndCol1
26+ statement :: Statement '[] SumAndCol1 Tables Tables
27 statement = select $
27 statement = select $
28 ((#col1 + #col2) `As` #sum :& #col1 :& RNil)
28 ((#col1 + #col2) `As` #sum :& #col1 :& RNil)
29 `from` (#table1 & where_ true)
29 `from` (#table1 & where_ true)
@@ -31,7 +31,7 @@ spec = do
31 "SELECT (col1 + col2) AS sum, col1 AS col1 FROM table1 AS table1 WHERE TRUE;"
31 "SELECT (col1 + col2) AS sum, col1 AS col1 FROM table1 AS table1 WHERE TRUE;"
32 it "combines WHEREs using AND" $ do
32 it "combines WHEREs using AND" $ do
34− statement :: Statement '[] Tables Tables SumAndCol1
34+ statement :: Statement '[] SumAndCol1 Tables Tables
35 statement = select $
35 statement = select $
36 ((#col1 + #col2) `As` #sum :& #col1 :& RNil)
36 ((#col1 + #col2) `As` #sum :& #col1 :& RNil)
37 `from` (#table1 & where_ true & where_ false)
37 `from` (#table1 & where_ true & where_ false)
@@ -40,45 +40,45 @@ spec = do
40 it "performs sub SELECTs" $ do
40 it "performs sub SELECTs" $ do
42 selection = ((#col1 + #col2) `As` #sum :& #col1 :& RNil) `from` #table1
42 selection = ((#col1 + #col2) `As` #sum :& #col1 :& RNil) `from` #table1
43− statement :: Statement '[] Tables Tables SumAndCol1
43+ statement :: Statement '[] SumAndCol1 Tables Tables
44 statement = select $ starFrom (subselect (selection `As` #sub))
44 statement = select $ starFrom (subselect (selection `As` #sub))
45 statement `shouldRenderAs`
45 statement `shouldRenderAs`
46 "SELECT * FROM SELECT (col1 + col2) AS sum, col1 AS col1 FROM table1 AS table1 AS sub;"
46 "SELECT * FROM SELECT (col1 + col2) AS sum, col1 AS col1 FROM table1 AS table1 AS sub;"
47 it "does LIMIT clauses" $ do
47 it "does LIMIT clauses" $ do
49− statement :: Statement '[] Tables Tables Columns
49+ statement :: Statement '[] Columns Tables Tables
50 statement = select $ starFrom (#table1 & limit 1)
50 statement = select $ starFrom (#table1 & limit 1)
51 statement `shouldRenderAs` "SELECT * FROM table1 AS table1 LIMIT 1;"
51 statement `shouldRenderAs` "SELECT * FROM table1 AS table1 LIMIT 1;"
52 it "should use the minimum of given LIMITs" $ do
52 it "should use the minimum of given LIMITs" $ do
54− statement :: Statement '[] Tables Tables Columns
54+ statement :: Statement '[] Columns Tables Tables
55 statement = select $ starFrom (#table1 & limit 1 & limit 2)
55 statement = select $ starFrom (#table1 & limit 1 & limit 2)
56 statement `shouldRenderAs`
56 statement `shouldRenderAs`
57 "SELECT * FROM table1 AS table1 LIMIT CASE WHEN (1 <= 2) THEN 1 ELSE 2 END;"
57 "SELECT * FROM table1 AS table1 LIMIT CASE WHEN (1 <= 2) THEN 1 ELSE 2 END;"
58 it "should render parameters using $ signs" $ do
58 it "should render parameters using $ signs" $ do
60− statement :: Statement '[ 'NotNull 'PGInt8] Tables Tables Columns
60+ statement :: Statement '[ 'NotNull 'PGInt8] Columns Tables Tables
61 statement = select $ starFrom (#table1 & limit param1)
61 statement = select $ starFrom (#table1 & limit param1)
62 statement `shouldRenderAs` "SELECT * FROM table1 AS table1 LIMIT $1;"
62 statement `shouldRenderAs` "SELECT * FROM table1 AS table1 LIMIT $1;"
63 it "does OFFSET clauses" $ do
63 it "does OFFSET clauses" $ do
65− statement :: Statement '[] Tables Tables Columns
65+ statement :: Statement '[] Columns Tables Tables
66 statement = select $ starFrom (#table1 & offset 1)
66 statement = select $ starFrom (#table1 & offset 1)
67 statement `shouldRenderAs` "SELECT * FROM table1 AS table1 OFFSET 1;"
67 statement `shouldRenderAs` "SELECT * FROM table1 AS table1 OFFSET 1;"
68 it "should use the sum of given OFFSETs" $ do
68 it "should use the sum of given OFFSETs" $ do
70− statement :: Statement '[] Tables Tables Columns
70+ statement :: Statement '[] Columns Tables Tables
71 statement = select $ starFrom (#table1 & offset 1 & offset 2)
71 statement = select $ starFrom (#table1 & offset 1 & offset 2)
72 statement `shouldRenderAs` "SELECT * FROM table1 AS table1 OFFSET (1 + 2);"
72 statement `shouldRenderAs` "SELECT * FROM table1 AS table1 OFFSET (1 + 2);"
73 it "correctly render simple INSERTs" $ do
73 it "correctly render simple INSERTs" $ do
75− statement :: Statement '[] Tables Tables '[]
75+ statement :: Statement '[] '[] Tables Tables
76 statement = insertInto #table1 $ 2 `As` #col1 :& 4 `As` #col2 :& RNil
76 statement = insertInto #table1 $ 2 `As` #col1 :& 4 `As` #col2 :& RNil
77 statement `shouldRenderAs`
77 statement `shouldRenderAs`
78 "INSERT INTO table1 (col1, col2) VALUES (2, 4);"
78 "INSERT INTO table1 (col1, col2) VALUES (2, 4);"
79 it "should be safe against SQL injection in literal text" $ do
79 it "should be safe against SQL injection in literal text" $ do
81− statement :: Statement '[] StudentsTable StudentsTable '[]
81+ statement :: Statement '[] '[] StudentsTable StudentsTable
82 statement = insertInto #students $
82 statement = insertInto #students $
83 "Robert'); DROP TABLE students;" `As` #name :& RNil
83 "Robert'); DROP TABLE students;" `As` #name :& RNil
84 statement `shouldRenderAs`
84 statement `shouldRenderAs`
@@ -91,7 +91,7 @@ spec = do
91 :& #shippers &. #shipperVal `As` #shipperVal :& RNil
91 :& #shippers &. #shipperVal `As` #shipperVal :& RNil
92 it "should render CROSS JOINs" $ do
92 it "should render CROSS JOINs" $ do
94− statement :: Statement '[] JoinTables JoinTables ValueColumns
94+ statement :: Statement '[] ValueColumns JoinTables JoinTables
95 statement = select $ vals `from`
95 statement = select $ vals `from`
96 (join (#orders & Cross #customers & Cross #shippers))
96 (join (#orders & Cross #customers & Cross #shippers))
97 statement `shouldRenderAs`
97 statement `shouldRenderAs`
@@ -111,7 +111,7 @@ spec = do
111 (#orders &. #customerID ==* #customers &. #customerID)
111 (#orders &. #customerID ==* #customers &. #customerID)
112 & Inner #shippers
112 & Inner #shippers
113 (#orders &. #shipperID ==* #shippers &. #shipperID)
113 (#orders &. #shipperID ==* #shippers &. #shipperID)
114− selection :: Statement '[] JoinTables JoinTables ValueColumns
114+ selection :: Statement '[] ValueColumns JoinTables JoinTables
115 selection = select $ vals `from` innerJoins
115 selection = select $ vals `from` innerJoins
116 selection `shouldRenderAs`
116 selection `shouldRenderAs`
@@ -125,7 +125,7 @@ spec = do
125 \ ON (orders.shipperID = shippers.shipperID);"
125 \ ON (orders.shipperID = shippers.shipperID);"
126 it "should render self JOINs" $ do
126 it "should render self JOINs" $ do
128− statement :: Statement '[] JoinTables JoinTables OrderColumns
128+ statement :: Statement '[] OrderColumns JoinTables JoinTables
129 statement = select $ #orders1 `dotStarFrom`
129 statement = select $ #orders1 `dotStarFrom`
130 (join (Table (#orders `As` #orders1)
130 (join (Table (#orders `As` #orders1)
131 & Cross (#orders `As` #orders2)))
131 & Cross (#orders `As` #orders2)))
@@ -135,13 +135,13 @@ spec = do
135 \ CROSS JOIN orders AS orders2;"
135 \ CROSS JOIN orders AS orders2;"
136 it "should render simple CREATE TABLE statements" $ do
136 it "should render simple CREATE TABLE statements" $ do
138− statement :: Statement '[] '[] Tables '[]
138+ statement :: Statement '[] '[] '[] Tables
139 statement = createTable #table1 (proxy# :: Proxy# Columns)
139 statement = createTable #table1 (proxy# :: Proxy# Columns)
140 statement `shouldRenderAs`
140 statement `shouldRenderAs`
141 "CREATE TABLE table1 (col1 int4 NOT NULL, col2 int4 NOT NULL);"
141 "CREATE TABLE table1 (col1 int4 NOT NULL, col2 int4 NOT NULL);"
142 it "should render DROP TABLE statements" $ do
142 it "should render DROP TABLE statements" $ do
144− statement :: Statement '[] Tables '[] '[]
144+ statement :: Statement '[] '[] Tables '[]
145 statement = dropTable #table1
145 statement = dropTable #table1
146 statement `shouldRenderAs` "DROP TABLE table1;"
146 statement `shouldRenderAs` "DROP TABLE table1;"