This project is archived and is in readonly mode.

#2626 ✓stale
bill

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

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>

Attachments

Pages