mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-14 22:32:07 +03:00
Fix typing of in'
operator.
This commit is contained in:
parent
9f9ce9414f
commit
a56d0c4e52
@ -139,7 +139,7 @@ userGroup0Aggregate =
|
||||
, g <- groupBy (ug ! snd' ?!? Group.name')
|
||||
, let uid = ug ! fst' ?! User.id'
|
||||
, let c = count uid
|
||||
, () <- having $ c .<. value 3
|
||||
, () <- having $ c `in'` values [1, 2]
|
||||
, () <- asc $ c
|
||||
]
|
||||
|
||||
|
@ -68,7 +68,9 @@ import qualified Database.Relational.Query.Expr.Unsafe as UnsafeExpr
|
||||
|
||||
import Database.Relational.Query.Pi (Pi, piZip)
|
||||
|
||||
import Database.Relational.Query.Projection (Projection, unsafeFromColumns, columns)
|
||||
import Database.Relational.Query.Projection
|
||||
(Projection, unsafeFromColumns, columns,
|
||||
ListProjection, unsafeShowSqlListProjection)
|
||||
import qualified Database.Relational.Query.Projection as Projection
|
||||
|
||||
|
||||
@ -124,8 +126,8 @@ valueFalse :: (SqlProjectable p, ProjectableMaybe p) => p (Maybe Bool)
|
||||
valueFalse = just $ value False
|
||||
|
||||
-- | Polymorphic proejction of SQL set value from Haskell list.
|
||||
values :: (SqlProjectable p, ShowConstantSQL t) => [t] -> p [t]
|
||||
values = unsafeProjectSqlTerms . map showConstantSQL
|
||||
values :: (SqlProjectable p, ShowConstantSQL t) => [t] -> ListProjection p t
|
||||
values = Projection.list . map value
|
||||
|
||||
|
||||
-- | Interface to get SQL term from projections.
|
||||
@ -282,8 +284,9 @@ monoBinOp' = monoBinOp . sqlBinOp
|
||||
|
||||
-- | Binary operator corresponding SQL /IN/ .
|
||||
in' :: (SqlProjectable p, ProjectableShowSql p)
|
||||
=> p t -> p [t] -> p (Maybe Bool)
|
||||
in' = unsafeBinOp (SQLs.in')
|
||||
=> p t -> ListProjection p t -> p (Maybe Bool)
|
||||
in' a lp = unsafeProjectSql . paren
|
||||
$ SQLs.in' (unsafeShowSql a) (unsafeShowSqlListProjection unsafeShowSql lp)
|
||||
|
||||
-- | Operator corresponding SQL /IS NULL/ .
|
||||
isNull :: (SqlProjectable p, ProjectableShowSql p)
|
||||
|
@ -163,6 +163,7 @@ list = List
|
||||
unsafeListProjectionFromSubQuery :: SubQuery -> ListProjection p t
|
||||
unsafeListProjectionFromSubQuery = Sub
|
||||
|
||||
-- | Map projection show operatoions and concatinate to single SQL expression.
|
||||
unsafeShowSqlListProjection :: (p t -> String) -> ListProjection p t -> String
|
||||
unsafeShowSqlListProjection sf = d where
|
||||
d (List ps) = sqlRowListString $ map sf ps
|
||||
|
Loading…
Reference in New Issue
Block a user