mirror of
https://github.com/github/rails.git
synced 2026-01-29 08:18:03 -05:00
Fixed issue that kept :select options from being scoped [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4036 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Fixed issue that kept :select options from being scoped [Rick]
|
||||
|
||||
* Fixed db_schema_import when binary types are present #3101 [DHH]
|
||||
|
||||
* Fixed that MySQL enums should always be returned as strings #3501 [DHH]
|
||||
|
||||
@@ -106,7 +106,7 @@ module ActiveRecord
|
||||
|
||||
def construct_scope
|
||||
{
|
||||
:find => { :from => construct_from, :conditions => construct_conditions, :joins => construct_joins },
|
||||
:find => { :from => construct_from, :conditions => construct_conditions, :joins => construct_joins, :select => construct_select },
|
||||
:create => { @reflection.primary_key_name => @owner.id }
|
||||
}
|
||||
end
|
||||
|
||||
@@ -873,7 +873,7 @@ module ActiveRecord #:nodoc:
|
||||
method_scoping.assert_valid_keys([ :find, :create ])
|
||||
|
||||
if f = method_scoping[:find]
|
||||
f.assert_valid_keys([ :conditions, :joins, :from, :offset, :limit, :readonly ])
|
||||
f.assert_valid_keys([ :conditions, :joins, :select, :from, :offset, :limit, :readonly ])
|
||||
f[:readonly] = true if !f[:joins].blank? && !f.has_key?(:readonly)
|
||||
end
|
||||
|
||||
@@ -980,7 +980,7 @@ module ActiveRecord #:nodoc:
|
||||
end
|
||||
|
||||
def construct_finder_sql(options)
|
||||
sql = "SELECT #{options[:select] || '*'} "
|
||||
sql = "SELECT #{scope(:find, :select) || options[:select] || '*'} "
|
||||
sql << "FROM #{scope(:find, :from) || options[:from] || table_name} "
|
||||
|
||||
add_joins!(sql, options)
|
||||
|
||||
@@ -316,6 +316,10 @@ class AssociationsJoinModelTest < Test::Unit::TestCase
|
||||
assert_equal new_author, authors(:david).reload.favorite_authors.first
|
||||
end
|
||||
|
||||
def test_has_many_through_uses_correct_attributes
|
||||
assert_nil posts(:thinking).tags.find_by_name("General").attributes["tag_id"]
|
||||
end
|
||||
|
||||
private
|
||||
# create dynamic Post models to allow different dependency options
|
||||
def find_post_with_dependency(post_id, association, association_name, dependency)
|
||||
|
||||
Reference in New Issue
Block a user