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.

include :select if it begins with 'DISTINCT'

#79

I've run into a problem where, for the sake of performance, I'm using :joins rather than :include to find records with a particular association (and no, I can't reverse the situation as I'm looking for several associations at once using 'WHERE field IN (x, y, z...)' and fetching all the associated objects then iterating is even worse) . To avoid duplicates, I'm using a :select => 'DISTINCT blah' but it's not being passed to count() in will_paginate. I know we got rid of the :select option a while back (I ran into the problems it caused myself) but can we include it if it begins with 'DISTINCT'?

I've tested this out in my project and everything works fine, even the bits where :select caused problems before. Unfortunately I can't seem to get sqlite working on my machine so can't test the plugin directly.

- James Coglan

Reported by Chris Wanstrath · August 14th, 2007 @ 07:44 PM

State: resolved
Milestone: none
Assigned to: Mislav Mislav

Activity

  1. Mislav
    Mislav
    • State changed from open to resolved

    Done in [403]

    October 7th, 2007 @ 08:42 PM

  2. DEkart
    DEkart

    It seems, this fix does not work. You should use 'if' statement instead of 'unless':

    if options[:select] and options[:select] =~ /^\s*DISTINCT/i

    excludees << :select

    end

    In this case this fix will work

    October 16th, 2007 @ 10:34 PM

  3. Mislav
    Mislav

    DEkart,

    What sense does that make? My solution has unit tests that passes.

    October 11th, 2007 @ 03:10 PM

  4. DEkart
    DEkart

    It works fine when e have one page of data, but does not work when you have at least 2 pages.

    October 16th, 2007 @ 10:34 PM

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.