diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-07-07 02:42:42 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-07-07 02:42:42 +0000 |
commit | 3fbfc13ee35e074b3efd69c8d6dfeafd461dd43c (patch) | |
tree | e5026e6053a4faebd98d5dd89f160e4ca4607672 /activerecord/lib/active_record | |
parent | fd65d89e07d57d809c69043b52a3a1319fb3c2ad (diff) | |
download | rails-3fbfc13ee35e074b3efd69c8d6dfeafd461dd43c.tar.gz rails-3fbfc13ee35e074b3efd69c8d6dfeafd461dd43c.tar.bz2 rails-3fbfc13ee35e074b3efd69c8d6dfeafd461dd43c.zip |
Move from select * to select tablename.* to avoid clobbering IDs. Closes #8889 [dasil003]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7167 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb | 1 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb index 2155ce8e30..b5f718ae52 100644 --- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb @@ -53,6 +53,7 @@ module ActiveRecord options[:conditions] = conditions options[:joins] = @join_sql options[:readonly] = finding_with_ambigious_select?(options[:select]) + options[:select] ||= '*' if options[:order] && @reflection.options[:order] options[:order] = "#{options[:order]}, #{@reflection.options[:order]}" diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 77b22aad6a..5ab761932f 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1109,7 +1109,7 @@ module ActiveRecord #:nodoc: def construct_finder_sql(options) scope = scope(:find) - sql = "SELECT #{(scope && scope[:select]) || options[:select] || '*'} " + sql = "SELECT #{(scope && scope[:select]) || options[:select] || (options[:joins] && table_name + '.*') || '*'} " sql << "FROM #{(scope && scope[:from]) || options[:from] || table_name} " add_joins!(sql, options, scope) |