This project is archived and is in readonly mode.
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
-
Greg Hazel October 12th, 2009 @ 11:58 PM
- Title changed from named scope and :select causing duplicate WHERE clause to scope and :select causing duplicate WHERE clause
-
Elliot Winkler October 13th, 2009 @ 04:18 AM
#2923 which I reported a while back also does a similar thing. I wonder if it's related.
-
Rohit Arondekar October 6th, 2010 @ 06:40 AM
- State changed from new to stale
- Importance changed from to
Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.
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>