This project is archived and is in readonly mode.
default_scope for select option builds invalid SQL.
Reported by bill | May 8th, 2009 @ 09:44 PM | in 3.x
This query failed in my app due to the fact that you can't declare multiple columns in the "SELECT count" fragment:
SELECT count(id,title) AS count_id_title FROM
resources
INNER JOIN resources_tags
ON
resources
.id = resources_tags
.resource_id
WHERE (((resources
.approved
= 1) AND
(resources_tags
.tag_id = 109 )) AND
(resources_tags
.tag_id = 109 )) )
The query was invoked by "m = Model.approved" in the controller and then calling "m.size" in the view.
This is declared in the model: default_scope :select => 'id,title' named_scope :approved, :conditions => { :approved => true }
Rails 2.3.2 MySQL 5.0 Win XP
Comments and changes to this ticket
-
Emili Parreño May 13th, 2009 @ 10:41 AM
- Tag set to activerecord, count, mysql, patch
Is an error in construct_count_options_from_args(*args) method when build the sql sentence
Fix for this bug in the pacth file
-
Rohit Arondekar October 9th, 2010 @ 04:18 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>