on dev help sign in
fix tests
commitca0f6785411a1c5569631258790b23c3f1998ac3 authorEitan Chatav <eitan.chatav@gmail.com> dateMon 3 Jul 2017, 16:14 (9 years ago) parent37fb231
2 files changed+7−11
squeel-postgresql/src/Squeel/PostgreSQL/Statement.hs+1−5 squeel-postgresql/test/Squeel/PostgreSQL/StatementSpec.hs+6−6
squeel-postgresql/src/Squeel/PostgreSQL/Statement.hs+1−5
@@ -139,11 +139,7 @@ instance PGNum ty
139139instance PGFractional ty
140140 => Fractional (Expression params tables ('Required (nullity ty))) where
141141 (/) = unsafeBinaryOp "/"
142− fromRational x = UnsafeExpression $ mconcat
143− [ fromString (show (numerator x)) <> "."
144− , "/"
145− , fromString (show (denominator x)) <> "."
146− ]
142+ fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
147143
148144instance (PGFloating ty, PGCast 'PGNumeric ty, PGTyped ty)
149145 => Floating (Expression params tables ('Required (nullity ty))) where
squeel-postgresql/test/Squeel/PostgreSQL/StatementSpec.hs+6−6
@@ -47,13 +47,13 @@ spec = do
4747 let
4848 statement :: Statement '[] Columns Tables Tables
4949 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.;"
5151 it "should use the minimum of given LIMITs" $ do
5252 let
5353 statement :: Statement '[] Columns Tables Tables
5454 statement = select $ starFrom (#table1 & limit 1 & limit 2)
5555 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;"
5757 it "should render parameters using $ signs" $ do
5858 let
5959 statement :: Statement '[ 'Required ('NotNull 'PGInt8)] Columns Tables Tables
@@ -63,18 +63,18 @@ spec = do
6363 let
6464 statement :: Statement '[] Columns Tables Tables
6565 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.;"
6767 it "should use the sum of given OFFSETs" $ do
6868 let
6969 statement :: Statement '[] Columns Tables Tables
7070 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.);"
7272 it "correctly render simple INSERTs" $ do
7373 let
7474 statement :: Statement '[] '[] Tables Tables
7575 statement = insertInto #table1 $ 2 `As` #col1 :* 4 `As` #col2 :* Nil
7676 statement `shouldRenderAs`
77− "INSERT INTO table1 (col1, col2) VALUES (2, 4);"
77+ "INSERT INTO table1 (col1, col2) VALUES (2., 4.);"
7878 it "should be safe against SQL injection in literal text" $ do
7979 let
8080 statement :: Statement '[] '[] StudentsTable StudentsTable
@@ -145,7 +145,7 @@ spec = do
145145 :* (int8 & notNull & default_ 8) `As` #col3
146146 :* Nil)
147147 `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.);"
149149 it "should render DROP TABLE statements" $ do
150150 let
151151 statement :: Statement '[] '[] Tables '[]