This project is archived and is in readonly mode.

#3369 ✓stale
Greg Hazel

scope and :select causing duplicate WHERE clause

Reported by Greg Hazel | October 12th, 2009 @ 11:57 PM

class Address < ActiveRecord:Base

  def Address.emails
    scoped(:select => "addresses.email").map(&:email)
  end
end


# This has a duplicated WHERE clause:

>> Address.scoped(:conditions => "1 = 1").emails
Address Load (0.0ms)  SELECT addresses.email FROM `addresses` WHERE ((1 = 1) AND (1 = 1))

# However spelling out the function by hand works:

>> Address.scoped(:conditions => "1 = 1").scoped(:select => "addresses.email").map(&:email)
Address Load (1.0ms)  SELECT addresses.email FROM `addresses` WHERE (1 = 1)

Comments and changes to this ticket

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages