-
Notifications
You must be signed in to change notification settings - Fork 170
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
It is very non-obvious how to apply limit/offset/order conditionally #491
Comments
I can use unnest ::
Q MySQL db (QNested s) (table (QExpr MySQL (QNested s))) ->
Q MySQL db s (table (QExpr MySQL s))
unnest = unsafeCoerce |
Oh okay, polymorphism saves the day! As long as I'm taking something that is let applyLimit ::
(forall s. Q MySQL db s (table (QExpr MySQL s))) ->
(forall s. Q MySQL db s (table (QExpr MySQL s)))
applyLimit x = case mbLimit of
Nothing -> x
Just n -> limit_ (toInteger n) x It's important not to use |
Yuck. We should document this... |
Thanks for reporting. |
Maybe it really is worth having a |
I'll reopen then. |
Is there a way to write the I'd be happy to open a PR for a |
I want to apply
limit_
conditionally, like this:This fails with
cannot construct the infinite type: s ~ QNested s
. I get thatlimit_
changes the type andid
doesn't, but I can't figure out what I can use instead ofid
. I thoughtsubselect_
could work, but I'm getting ugly nested queries whenlimitNeeded
is false:Any advice?
The text was updated successfully, but these errors were encountered: