@@ -8,6 +8,7 @@
8module Squeel.PostgreSQL.QuerySpec where
8module Squeel.PostgreSQL.QuerySpec where
10import Data.Boolean
10import Data.Boolean
11import Data.Proxy
12import Data.Proxy
12import Data.Vinyl
13import Data.Vinyl
13import Test.Hspec
14import Test.Hspec
@@ -18,11 +19,11 @@ import Squeel.PostgreSQL.Type
18spec :: Spec
19spec :: Spec
20 it "correctly renders a simple SELECT query" $ do
21 it "correctly renders a simple SELECT query" $ do
21− renderQuery (select (sumAndCol1 `from` (table1 `where_` true)))
22+ renderQuery (select (sumAndCol1 `from` (table1 & where_ true)))
22 `shouldBe`
23 `shouldBe`
23 "SELECT col1+col2 AS sum, col1 AS col1 FROM table1 WHERE TRUE;"
24 "SELECT col1+col2 AS sum, col1 AS col1 FROM table1 WHERE TRUE;"
24 it "combines WHEREs using AND" $ do
25 it "combines WHEREs using AND" $ do
25− renderQuery (select (sumAndCol1 `from` (table1 `where_` true `where_` false)))
26+ renderQuery (select (sumAndCol1 `from` (table1 & where_ true & where_ false)))
26 `shouldBe`
27 `shouldBe`
27 "SELECT col1+col2 AS sum, col1 AS col1 FROM table1 WHERE TRUE AND FALSE;"
28 "SELECT col1+col2 AS sum, col1 AS col1 FROM table1 WHERE TRUE AND FALSE;"
28 it "performs subSELECTs" $ do
29 it "performs subSELECTs" $ do
@@ -30,23 +31,23 @@ spec = do
30 `shouldBe`
31 `shouldBe`
31 "SELECT * FROM SELECT col1+col2 AS sum, col1 AS col1 FROM table1;"
32 "SELECT * FROM SELECT col1+col2 AS sum, col1 AS col1 FROM table1;"
32 it "does LIMIT clauses" $ do
33 it "does LIMIT clauses" $ do
33− renderQuery (select (star `from` (table1 `limit` 1)))
34+ renderQuery (select (star `from` (table1 & limit 1)))
34 `shouldBe`
35 `shouldBe`
35 "SELECT * FROM table1 LIMIT 1;"
36 "SELECT * FROM table1 LIMIT 1;"
36 it "should use the minimum of given LIMITs" $ do
37 it "should use the minimum of given LIMITs" $ do
37− renderQuery (select (star `from` (table1 `limit` 1 `limit` 2)))
38+ renderQuery (select (star `from` (table1 & limit 1 & limit 2)))
38 `shouldBe`
39 `shouldBe`
39 "SELECT * FROM table1 LIMIT CASE WHEN 1<=2 THEN 1 ELSE 2 END;"
40 "SELECT * FROM table1 LIMIT CASE WHEN 1<=2 THEN 1 ELSE 2 END;"
40 it "should render parameters using $ signs" $ do
41 it "should render parameters using $ signs" $ do
41− renderQuery (select (star `from` (parameterizedTable1 `limit` param1)))
42+ renderQuery (select (star `from` (parameterizedTable1 & limit param1)))
42 `shouldBe`
43 `shouldBe`
43 "SELECT * FROM table1 LIMIT $1;"
44 "SELECT * FROM table1 LIMIT $1;"
44 it "does OFFSET clauses" $ do
45 it "does OFFSET clauses" $ do
45− renderQuery (select (star `from` (table1 `offset` 1)))
46+ renderQuery (select (star `from` (table1 & offset 1)))
46 `shouldBe`
47 `shouldBe`
47 "SELECT * FROM table1 OFFSET 1;"
48 "SELECT * FROM table1 OFFSET 1;"
48 it "should use the sum of given OFFSETs" $ do
49 it "should use the sum of given OFFSETs" $ do
49− renderQuery (select (star `from` (table1 `offset` 1 `offset` 2)))
50+ renderQuery (select (star `from` (table1 & offset 1 & offset 2)))
50 `shouldBe`
51 `shouldBe`
51 "SELECT * FROM table1 OFFSET 1+2;"
52 "SELECT * FROM table1 OFFSET 1+2;"
52 it "correctly render simple INSERTs" $ do
53 it "correctly render simple INSERTs" $ do