LIMIT clauses accumulate, anger PostgreSQL
-
Matthew King
Attached is a patch with a test that demonstrates the accumulation problem. Easy to reproduce: just run Query#first with an argument more than once on the same query.
I think that LIMIT and OFFSET ought to be one-time additions to the query, so we don't store them in @clauses. I'm playing with a fix that adds them as args to Query#to_hash and Query#to_s. Will upload patch soon.
-
Matthew King
Here is a patch (with tests!) that substantially changes the way Ambition::Limit works.
It solves the PostgreSQL problem by breaking out limit and offset into separate SQL clauses. This is much better for readability, by the way. Figuring out what was going on with the reversed-argument calls to first from [] really hurt my head. Tests are much clearer, too.
It solves the accumulating clauses problem by making the limit and offset values into args for the kicker method
-
Matthew King
- Title changed from LIMIT clauses accumulate, anger PostgreSQL unbearably to LIMIT clauses accumulate, anger PostgreSQL
-
Chris Wanstrath
- State changed from new to open
Looking at this now, just wanted to say that it's a bug that #first(3) is a kicker. Definitely should not be. So this patch is built upon my bug, but I'll mess around with it.
-
Chris Wanstrath
Should be fixed, thanks!
-
Chris Wanstrath
- State changed from open to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
