rel8
rel8 copied to clipboard
Dynamic limit and offset
Is PG this universally happy with this? It probably is, but for some reason I feel this comes with caveats!
Is PG this universally happy with this? It probably is, but for some reason I feel this comes with caveats!
If there's any kind of tradeoff involved, could we keep the old limit and call this one something else?
At my workplace we have this code in our utilities and I'm excited to replace it with this PR!
-- | A workaround for the fact that Rel8 doesn't expose a version of LIMIT with
-- an `Expr` for the count.
dynamicLimit :: (DBIntegral n) => Expr n -> Query a -> Query a
dynamicLimit n q = do
(i, v) <- indexed q
where_ $ i <. Rel8.fromIntegral n
pure v
Yeah, it would be good to give the dynamic version a new name and avoid a breaking change to the old versions IMO