This project is archived and is in readonly mode.
ActiveRecord::Base.construct_finder_sql gives scope[:from] precedence over options[:from]
Reported by John Wulff | November 13th, 2008 @ 10:08 PM | in 2.x
In activerecord/lib/active_record/base.rb
module ActiveRecord
...
class Base
...
class << self
...
def construct_finder_sql(options)
...
sql = "SELECT #{options[:select] || (scope && scope[:select]) || ((options[:joins] || (scope && scope[:joins])) && quoted_table_name + '.*') || '*'} "
sql << "FROM #{(scope && scope[:from]) || options[:from] || quoted_table_name} "
...
construct_finder_sql gives precedence to the options hash over the scope for query construction except for the "FROM" clause. This disallows "FROM" overriding when manually calling construct_finder_sql.
I propose that
sql << "FROM #{(scope && scope[:from]) || options[:from] || quoted_table_name} "
be changed to:
sql << "FROM #{options[:from] || (scope && scope[:from]) || quoted_table_name} "
Comments and changes to this ticket
-
DHH November 16th, 2008 @ 02:52 PM
- Tag changed from activerecord to activerecord, patch
Looks good to me, but we should have a test that verifies this behavior (one that fails before this patch and passes after).
-
Repository March 6th, 2009 @ 06:38 PM
- State changed from new to resolved
(from [4863634a157a8e4a0033734617253b42325daf34]) Ensure supplie :from has precedence over scoped :from [#1370 state:resolved] http://github.com/rails/rails/co...
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>
People watching this ticket
Attachments
Tags
Referenced by
- 1370 ActiveRecord::Base.construct_finder_sql gives scope[:from] precedence over options[:from] (from [4863634a157a8e4a0033734617253b42325daf34]) Ensure ...