on dev help sign in
fix tests
ca0f678Eitan Chatav
squeel-postgresql/src/Squeel/PostgreSQL/Statement.hs+1−5
@@ -139,11 +139,7 @@ instance PGNum ty
139instance PGFractional ty
139instance PGFractional ty
140 => Fractional (Expression params tables ('Required (nullity ty))) where
140 => Fractional (Expression params tables ('Required (nullity ty))) where
141 (/) = unsafeBinaryOp "/"
141 (/) = unsafeBinaryOp "/"
142− fromRational x = UnsafeExpression $ mconcat
142+ fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
143− [ fromString (show (numerator x)) <> "."
144− , "/"
145− , fromString (show (denominator x)) <> "."
146− ]
147
143
148instance (PGFloating ty, PGCast 'PGNumeric ty, PGTyped ty)
144instance (PGFloating ty, PGCast 'PGNumeric ty, PGTyped ty)
149 => Floating (Expression params tables ('Required (nullity ty))) where
145 => Floating (Expression params tables ('Required (nullity ty))) where
squeel-postgresql/test/Squeel/PostgreSQL/StatementSpec.hs+6−6
@@ -47,13 +47,13 @@ spec = do
47 let
47 let
48 statement :: Statement '[] Columns Tables Tables
48 statement :: Statement '[] Columns Tables Tables
49 statement = select $ starFrom (#table1 & limit 1)
49 statement = select $ starFrom (#table1 & limit 1)
50− statement `shouldRenderAs` "SELECT * FROM table1 AS table1 LIMIT 1;"
50+ statement `shouldRenderAs` "SELECT * FROM table1 AS table1 LIMIT 1.;"
51 it "should use the minimum of given LIMITs" $ do
51 it "should use the minimum of given LIMITs" $ do
52 let
52 let
53 statement :: Statement '[] Columns Tables Tables
53 statement :: Statement '[] Columns Tables Tables
54 statement = select $ starFrom (#table1 & limit 1 & limit 2)
54 statement = select $ starFrom (#table1 & limit 1 & limit 2)
55 statement `shouldRenderAs`
55 statement `shouldRenderAs`
56− "SELECT * FROM table1 AS table1 LIMIT CASE WHEN (1 <= 2) THEN 1 ELSE 2 END;"
56+ "SELECT * FROM table1 AS table1 LIMIT CASE WHEN (1. <= 2.) THEN 1. ELSE 2. END;"
57 it "should render parameters using $ signs" $ do
57 it "should render parameters using $ signs" $ do
58 let
58 let
59 statement :: Statement '[ 'Required ('NotNull 'PGInt8)] Columns Tables Tables
59 statement :: Statement '[ 'Required ('NotNull 'PGInt8)] Columns Tables Tables
@@ -63,18 +63,18 @@ spec = do
63 let
63 let
64 statement :: Statement '[] Columns Tables Tables
64 statement :: Statement '[] Columns Tables Tables
65 statement = select $ starFrom (#table1 & offset 1)
65 statement = select $ starFrom (#table1 & offset 1)
66− statement `shouldRenderAs` "SELECT * FROM table1 AS table1 OFFSET 1;"
66+ statement `shouldRenderAs` "SELECT * FROM table1 AS table1 OFFSET 1.;"
67 it "should use the sum of given OFFSETs" $ do
67 it "should use the sum of given OFFSETs" $ do
68 let
68 let
69 statement :: Statement '[] Columns Tables Tables
69 statement :: Statement '[] Columns Tables Tables
70 statement = select $ starFrom (#table1 & offset 1 & offset 2)
70 statement = select $ starFrom (#table1 & offset 1 & offset 2)
71− statement `shouldRenderAs` "SELECT * FROM table1 AS table1 OFFSET (1 + 2);"
71+ statement `shouldRenderAs` "SELECT * FROM table1 AS table1 OFFSET (1. + 2.);"
72 it "correctly render simple INSERTs" $ do
72 it "correctly render simple INSERTs" $ do
73 let
73 let
74 statement :: Statement '[] '[] Tables Tables
74 statement :: Statement '[] '[] Tables Tables
75 statement = insertInto #table1 $ 2 `As` #col1 :* 4 `As` #col2 :* Nil
75 statement = insertInto #table1 $ 2 `As` #col1 :* 4 `As` #col2 :* Nil
76 statement `shouldRenderAs`
76 statement `shouldRenderAs`
77− "INSERT INTO table1 (col1, col2) VALUES (2, 4);"
77+ "INSERT INTO table1 (col1, col2) VALUES (2., 4.);"
78 it "should be safe against SQL injection in literal text" $ do
78 it "should be safe against SQL injection in literal text" $ do
79 let
79 let
80 statement :: Statement '[] '[] StudentsTable StudentsTable
80 statement :: Statement '[] '[] StudentsTable StudentsTable
@@ -145,7 +145,7 @@ spec = do
145 :* (int8 & notNull & default_ 8) `As` #col3
145 :* (int8 & notNull & default_ 8) `As` #col3
146 :* Nil)
146 :* Nil)
147 `shouldRenderAs`
147 `shouldRenderAs`
148− "CREATE TABLE table2 (col1 serial, col2 text, col3 int8 NOT NULL DEFAULT 8);"
148+ "CREATE TABLE table2 (col1 serial, col2 text, col3 int8 NOT NULL DEFAULT 8.);"
149 it "should render DROP TABLE statements" $ do
149 it "should render DROP TABLE statements" $ do
150 let
150 let
151 statement :: Statement '[] '[] Tables '[]
151 statement :: Statement '[] '[] Tables '[]