This project is archived and is in readonly mode.
ActiveRecord adds comma to query's column list when referring to a model with a default_scope select()
Reported by Brian Underwood | August 10th, 2010 @ 09:21 PM
I have two basic models (sample Rails app with a failing test attached):
class Bar < ActiveRecord::Base
default_scope select('id')
has_many :bazs
end
class Baz < ActiveRecord::Base
belongs_to :bar
end
When I try to refer to a "bar" object on a "Baz" object, I get an error (Either a PGError or SQLite3::SQLException in the case of my sample app). This seems to do with having a default_scope with a select() scoping on the targetted object.
When I go to belongs_to_association.rb and comment out the following line in BelongsToAssociation#find_target it seems to work fine:
:select => @reflection.options[:select],
That's obviously not a solution, but it might narrow down the search for the issue.
I'm using:
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-darwin10.4.0]
Rails 3.0.0.rc
Comments and changes to this ticket
-
Henrik Hodne August 11th, 2010 @ 01:14 AM
Try using rails 1.9.2. Rails 3 is not compatible with 1.8 AFAIK.
-
Brian Underwood August 11th, 2010 @ 01:30 PM
http://edgeguides.rubyonrails.org/3_0_release_notes.html?utm_source...
"Rails 3.0 requires Ruby 1.8.7 or higher. Support for all of the previous Ruby versions has been dropped officially and you should upgrade as early as possible. Rails 3.0 is also compatible with Ruby 1.9.2."
http://paulbarry.com/articles/2009/09/14/why-rails-3-will-require-r...
-
Rohit Arondekar October 7th, 2010 @ 05:21 AM
- Tag changed from activerecord associations, rails3rc, tests to activerecord, associations, rails3rc, tests
-
David Trasbo October 7th, 2010 @ 09:20 PM
- Importance changed from to Low
If you want this fixed, pretty much the only way to go is providing a patch with a fix yourself or at least one with a failing test case.
-
Brian Underwood October 18th, 2010 @ 03:03 PM
Sorry for not getting back on this sooner, but it seems to be working fine in 3.0.0 (though I just upgraded to 3.0.1 as well ;). I believe I was on a RC when seeing this bug.
-
Santiago Pastorino February 2nd, 2011 @ 04:29 PM
- State changed from new to open
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino February 2nd, 2011 @ 04:29 PM
- State changed from open to stale
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>