#100 ✓resolved
Matthew King

LIMIT clauses accumulate, anger PostgreSQL

Reported by Matthew King | August 30th, 2007 @ 06:26 PM

Each time you kick a first or [] off of a query using a limit or offset, it accumulates a LimitProcessor in keyed_clauses[:limit].

Additionally, PostgreSQL does not support the LIMIT #,# syntax for specifying a limit and offset concisely.

Comments and changes to this ticket

  • Matthew King

    Matthew King August 30th, 2007 @ 06:30 PM

    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

    Matthew King August 30th, 2007 @ 06:35 PM

    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

    Matthew King August 30th, 2007 @ 06:38 PM

    • Title changed from “LIMIT clauses accumulate, anger PostgreSQL unbearably” to “LIMIT clauses accumulate, anger PostgreSQL”
  • Chris Wanstrath

    Chris Wanstrath September 1st, 2007 @ 03:21 PM

    • 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
  • Chris Wanstrath

    Chris Wanstrath September 2nd, 2007 @ 02:52 AM

    • 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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Attachments

Tags

Pages