#100 ✓resolved
Matthew King

LIMIT clauses accumulate, anger PostgreSQL

Reported by Matthew King | 2007-08-30 18:26:57 UTC

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 2007-08-30 18:30:11 UTC

    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 2007-08-30 18:35:07 UTC

    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 2007-08-30 18:38:39 UTC

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

    Chris Wanstrath 2007-09-01 15:21:11 UTC

    • 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 2007-09-02 02:52:09 UTC

    • 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