Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

LIMIT clauses accumulate, anger PostgreSQL

#100

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.

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

State: resolved
Milestone: none
Assigned to: Chris Wanstrath Chris Wanstrath

Activity

  1. Matthew King
    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.

    August 30th, 2007 @ 06:30 PM

  2. Matthew King
    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

    August 30th, 2007 @ 06:35 PM

  3. Matthew King
    Matthew King
    • Title changed from LIMIT clauses accumulate, anger PostgreSQL unbearably to LIMIT clauses accumulate, anger PostgreSQL

    August 30th, 2007 @ 06:38 PM

  4. Chris Wanstrath
    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.

    September 1st, 2007 @ 03:21 PM

  5. Chris Wanstrath
  6. Chris Wanstrath
    Chris Wanstrath
    • State changed from open to resolved

    September 2nd, 2007 @ 02:52 AM

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.