Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

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()

#5353

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

Reported by Brian Underwood · August 10th, 2010 @ 09:21 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Henrik Hodne
    Henrik Hodne

    Try using rails 1.9.2. Rails 3 is not compatible with 1.8 AFAIK.

    August 11th, 2010 @ 01:14 AM

  2. Brian Underwood
    Brian Underwood

    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...

    August 11th, 2010 @ 01:30 PM

  3. Rohit Arondekar
    Rohit Arondekar
    • Tag changed from activerecord associations, rails3rc, tests to activerecord, associations, rails3rc, tests

    October 7th, 2010 @ 05:21 AM

  4. David Trasbo
    David Trasbo
    • 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.

    October 7th, 2010 @ 09:20 PM

  5. Brian Underwood
    Brian Underwood

    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.

    October 18th, 2010 @ 03:03 PM

  6. Santiago Pastorino
    Santiago Pastorino
    • 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.

    February 2nd, 2011 @ 04:29 PM

  7. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:29 PM

  8. Brian Underwood
    Brian Underwood

    Feel free to close this ticket. I believe it was resolved by #5845

    Also, you might be able to close #1860 as well, I believe it's the same issue.

    February 7th, 2011 @ 04:38 PM