@@ -16,8 +16,8 @@
17module Squeel.PostgreSQL.Statement where
17module Squeel.PostgreSQL.Statement where
19−import Data.Boolean
19+-- import Data.Boolean
20−import Data.Boolean.Numbers
20+-- import Data.Boolean.Numbers
21import Data.ByteString (ByteString)
21import Data.ByteString (ByteString)
22import Data.Foldable
22import Data.Foldable
23import Data.Maybe
23import Data.Maybe
@@ -200,52 +200,52 @@ instance PGCast 'PGInt8 'PGFloat4
200instance PGCast 'PGInt8 'PGFloat8
200instance PGCast 'PGInt8 'PGFloat8
201instance PGCast 'PGInt8 'PGNumeric
201instance PGCast 'PGInt8 'PGNumeric
203−instance (PGNum ty, PGTyped ty, PGCast 'PGInt8 ty)
203+-- instance (PGNum ty, PGTyped ty, PGCast 'PGInt8 ty)
204− => NumB (Expression params tables ('Required (nullity ty))) where
204+-- => NumB (Expression params tables ('Required (nullity ty))) where
205− type IntegerOf (Expression params tables ('Required (nullity ty)))
205+-- type IntegerOf (Expression params tables ('Required (nullity ty)))
206− = (Expression params tables ('Required (nullity 'PGInt8)))
206+-- = (Expression params tables ('Required (nullity 'PGInt8)))
207− fromIntegerB = cast pgtype
207+-- fromIntegerB = cast pgtype
209−instance (PGNum ty, PGTyped ty, PGCast 'PGInt8 ty, PGCast ty 'PGInt8)
209+-- instance (PGNum ty, PGTyped ty, PGCast 'PGInt8 ty, PGCast ty 'PGInt8)
210− => IntegralB (Expression params tables ('Required ('NotNull ty))) where
210+-- => IntegralB (Expression params tables ('Required ('NotNull ty))) where
211− quot = unsafeBinaryOp "/"
211+-- quot = unsafeBinaryOp "/"
212− rem = unsafeBinaryOp "%"
212+-- rem = unsafeBinaryOp "%"
213− div = unsafeBinaryOp "/"
213+-- div = unsafeBinaryOp "/"
214− mod = unsafeBinaryOp "%"
214+-- mod = unsafeBinaryOp "%"
215− toIntegerB = cast int8
215+-- toIntegerB = cast int8
217−instance
217+-- instance
218− ( IntegerOf (Expression params tables ('Required ('NotNull ty)))
218+-- ( IntegerOf (Expression params tables ('Required ('NotNull ty)))
219− ~ (Expression params tables ('Required ('NotNull 'PGInt8)))
219+-- ~ (Expression params tables ('Required ('NotNull 'PGInt8)))
220− , PGNum ty
220+-- , PGNum ty
221− , PGTyped ty
221+-- , PGTyped ty
222− , PGCast 'PGInt8 ty
222+-- , PGCast 'PGInt8 ty
223− , PGFractional ty
223+-- , PGFractional ty
225− => RealFracB (Expression params tables ('Required ('NotNull ty))) where
225+-- => RealFracB (Expression params tables ('Required ('NotNull ty))) where
226− properFraction x = (truncate x, x - unsafeFunction "trunc" x)
226+-- properFraction x = (truncate x, x - unsafeFunction "trunc" x)
227− truncate = fromIntegerB . unsafeFunction "trunc"
227+-- truncate = fromIntegerB . unsafeFunction "trunc"
228− round = fromIntegerB . unsafeFunction "round"
228+-- round = fromIntegerB . unsafeFunction "round"
229− ceiling = fromIntegerB . unsafeFunction "ceiling"
229+-- ceiling = fromIntegerB . unsafeFunction "ceiling"
230− floor = fromIntegerB . unsafeFunction "floor"
230+-- floor = fromIntegerB . unsafeFunction "floor"
232−instance
232+-- instance
233− ( IntegerOf (Expression params tables ('Required ('NotNull ty)))
233+-- ( IntegerOf (Expression params tables ('Required ('NotNull ty)))
234− ~ (Expression params tables ('Required ('NotNull 'PGInt8)))
234+-- ~ (Expression params tables ('Required ('NotNull 'PGInt8)))
235− , PGNum ty
235+-- , PGNum ty
236− , PGTyped ty
236+-- , PGTyped ty
237− , PGCast 'PGInt8 ty
237+-- , PGCast 'PGInt8 ty
238− , PGCast 'PGNumeric ty
238+-- , PGCast 'PGNumeric ty
239− , PGFloating ty
239+-- , PGFloating ty
241− => RealFloatB (Expression params tables ('Required ('NotNull ty))) where
241+-- => RealFloatB (Expression params tables ('Required ('NotNull ty))) where
242− isNaN x = x ==* UnsafeExpression "\'NaN\'"
242+-- isNaN x = x ==* UnsafeExpression "\'NaN\'"
243− isInfinite x = x ==* UnsafeExpression "\'Infinity\'"
243+-- isInfinite x = x ==* UnsafeExpression "\'Infinity\'"
244− ||* x ==* UnsafeExpression "\'-Infinity\'"
244+-- ||* x ==* UnsafeExpression "\'-Infinity\'"
245− isNegativeZero x = x ==* UnsafeExpression "-0"
245+-- isNegativeZero x = x ==* UnsafeExpression "-0"
246− isIEEE _ = true
246+-- isIEEE _ = true
247− atan2 y x = UnsafeExpression $
247+-- atan2 y x = UnsafeExpression $
248− "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
248+-- "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
250instance IsString (Expression params tables ('Required (nullity 'PGText))) where
250instance IsString (Expression params tables ('Required (nullity 'PGText))) where
251 fromString str = UnsafeExpression $
251 fromString str = UnsafeExpression $
@@ -262,15 +262,28 @@ instance IsString (Expression params tables ('Required (nullity 'PGText))) where
262 '\\' -> "\\\\"
262 '\\' -> "\\\\"
265−instance Boolean (Expression params tables ('Required ('NotNull 'PGBool))) where
265+-- instance Boolean (Expression params tables ('Required ('NotNull 'PGBool))) where
266+true :: Expression params tables ('Required ('NotNull 'PGBool))
266− true = UnsafeExpression "TRUE"
267+true = UnsafeExpression "TRUE"
268+false :: Expression params tables ('Required ('NotNull 'PGBool))
267− false = UnsafeExpression "FALSE"
269+false = UnsafeExpression "FALSE"
271+ :: Expression params tables ('Required ('NotNull 'PGBool))
272+ -> Expression params tables ('Required ('NotNull 'PGBool))
268− notB = unsafeUnaryOp "NOT"
273+notB = unsafeUnaryOp "NOT"
275+ :: Expression params tables ('Required ('NotNull 'PGBool))
276+ -> Expression params tables ('Required ('NotNull 'PGBool))
277+ -> Expression params tables ('Required ('NotNull 'PGBool))
269− (&&*) = unsafeBinaryOp "AND"
278+(&&*) = unsafeBinaryOp "AND"
280+ :: Expression params tables ('Required ('NotNull 'PGBool))
281+ -> Expression params tables ('Required ('NotNull 'PGBool))
282+ -> Expression params tables ('Required ('NotNull 'PGBool))
270− (||*) = unsafeBinaryOp "OR"
283+(||*) = unsafeBinaryOp "OR"
272−type instance BooleanOf (Expression params tables ty) =
285+-- type instance BooleanOf (Expression params tables ty) =
273− Expression params tables ('Required ('NotNull 'PGBool))
286+-- Expression params tables ('Required ('NotNull 'PGBool))
275caseWhenThenElse
288caseWhenThenElse
276 :: [(Expression params tables ('Required ('NotNull 'PGBool)), Expression params tables ty)]
289 :: [(Expression params tables ('Required ('NotNull 'PGBool)), Expression params tables ty)]
@@ -289,18 +302,47 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
292−instance IfB (Expression params tables ty) where
305+-- instance IfB (Expression params tables ty) where
307+ :: Expression params tables ('Required ('NotNull 'PGBool))
308+ -> Expression params tables ty
309+ -> Expression params tables ty
310+ -> Expression params tables ty
293− ifB if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
311+ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
295−instance EqB (Expression params tables (optionality ('NotNull ty))) where
313+-- instance EqB (Expression params tables (optionality ('NotNull ty))) where
315+ :: Expression params tables ty
316+ -> Expression params tables ty
317+ -> Expression params tables ('Required ('NotNull 'PGBool))
296− (==*) = unsafeBinaryOp "="
318+(==*) = unsafeBinaryOp "="
320+ :: Expression params tables ty
321+ -> Expression params tables ty
322+ -> Expression params tables ('Required ('NotNull 'PGBool))
297− (/=*) = unsafeBinaryOp "<>"
323+(/=*) = unsafeBinaryOp "<>"
299−instance OrdB (Expression params tables (optionality ('NotNull ty))) where
325+-- instance OrdB (Expression params tables (optionality ('NotNull ty))) where
300− (>*) = unsafeBinaryOp ">"
326+(>=*)
327+ :: Expression params tables ty
328+ -> Expression params tables ty
329+ -> Expression params tables ('Required ('NotNull 'PGBool))
301− (>=*) = unsafeBinaryOp ">="
330+(>=*) = unsafeBinaryOp ">="
332+ :: Expression params tables ty
333+ -> Expression params tables ty
334+ -> Expression params tables ('Required ('NotNull 'PGBool))
302− (<*) = unsafeBinaryOp "<"
335+(<*) = unsafeBinaryOp "<"
337+ :: Expression params tables ty
338+ -> Expression params tables ty
339+ -> Expression params tables ('Required ('NotNull 'PGBool))
303− (<=*) = unsafeBinaryOp "<="
340+(<=*) = unsafeBinaryOp "<="
342+ :: Expression params tables ty
343+ -> Expression params tables ty
344+ -> Expression params tables ('Required ('NotNull 'PGBool))
345+(>*) = unsafeBinaryOp ">"
305{-----------------------------------------
347{-----------------------------------------