File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 1- packages : .
1+ packages : ., ../opaleye/*.cabal
22constraints : ansi-wl-pprint < 1.0.0
33allow-newer : base16 :base, base16 :deepseq, base16 :text
Original file line number Diff line number Diff line change 1+ {-# language LambdaCase #-}
2+
13module Rel8.Query.Limit
24 ( limit
35 , offset
46 )
57where
68
79-- base
10+ import Data.Int (Int64 )
811import Prelude
912
1013-- opaleye
1114import qualified Opaleye
15+ import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye
1216
1317-- rel8
18+ import Rel8.Expr (Expr )
19+ import Rel8.Expr.Opaleye (toColumn , toPrimExpr )
1420import Rel8.Query ( Query )
1521import Rel8.Query.Opaleye ( mapOpaleye )
1622
1723
1824-- | @limit n@ select at most @n@ rows from a query. @limit n@ is equivalent
1925-- to the SQL @LIMIT n@.
20- limit :: Word -> Query a -> Query a
21- limit = mapOpaleye . Opaleye. limit . fromIntegral
26+ limit :: Expr Int64 -> Query a -> Query a
27+ limit = mapOpaleye . Opaleye. limitField . toColumn . stripCast . toPrimExpr
2228
2329
2430-- | @offset n@ drops the first @n@ rows from a query. @offset n@ is equivalent
2531-- to the SQL @OFFSET n@.
26- offset :: Word -> Query a -> Query a
27- offset = mapOpaleye . Opaleye. offset . fromIntegral
32+ offset :: Expr Int64 -> Query a -> Query a
33+ offset = mapOpaleye . Opaleye. offsetField . toColumn . stripCast . toPrimExpr
34+
35+
36+ stripCast :: Opaleye. PrimExpr -> Opaleye. PrimExpr
37+ stripCast = \ case
38+ Opaleye. CastExpr " \" int8\" " a -> a
39+ a -> a
You can’t perform that action at this time.
0 commit comments