File tree 2 files changed +17
-5
lines changed
2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 1
- packages : .
1
+ packages : ., ../opaleye/*.cabal
2
2
constraints : ansi-wl-pprint < 1.0.0
3
3
allow-newer : base16 :base, base16 :deepseq, base16 :text
Original file line number Diff line number Diff line change
1
+ {-# language LambdaCase #-}
2
+
1
3
module Rel8.Query.Limit
2
4
( limit
3
5
, offset
4
6
)
5
7
where
6
8
7
9
-- base
10
+ import Data.Int (Int64 )
8
11
import Prelude
9
12
10
13
-- opaleye
11
14
import qualified Opaleye
15
+ import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye
12
16
13
17
-- rel8
18
+ import Rel8.Expr (Expr )
19
+ import Rel8.Expr.Opaleye (toColumn , toPrimExpr )
14
20
import Rel8.Query ( Query )
15
21
import Rel8.Query.Opaleye ( mapOpaleye )
16
22
17
23
18
24
-- | @limit n@ select at most @n@ rows from a query. @limit n@ is equivalent
19
25
-- 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
22
28
23
29
24
30
-- | @offset n@ drops the first @n@ rows from a query. @offset n@ is equivalent
25
31
-- 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