Skip to content

Dynamic limit and offset #361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Dynamic limit and offset #361

wants to merge 1 commit into from

Conversation

shane-circuithub
Copy link
Contributor

No description provided.

@shane-circuithub shane-circuithub force-pushed the dynamic-limit branch 2 times, most recently from e46169e to 6bedb7b Compare January 29, 2025 22:11
@ocharles
Copy link
Contributor

Is PG this universally happy with this? It probably is, but for some reason I feel this comes with caveats!

@@ -1,3 +1,3 @@
packages: .
packages: ., ../opaleye/*.cabal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you meant to commit this.

@sfwc
Copy link

sfwc commented Jan 31, 2025

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

@TeofilC
Copy link
Contributor

TeofilC commented Jan 31, 2025

Yeah, it would be good to give the dynamic version a new name and avoid a breaking change to the old versions IMO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants