aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorKassio Borges <kassioborgesm@gmail.com>2013-12-13 11:37:19 -0200
committerKassio Borges <kassioborgesm@gmail.com>2013-12-13 11:55:13 -0200
commitb8569b9337309c2d6c72566a3426994b6da443d7 (patch)
tree17f7bbfffe28df27abd4faa14b7aa29d9a4ce50e /activerecord/lib/active_record
parent7ce846c17784f8fca930c850ab6dae3555b66f8c (diff)
downloadrails-b8569b9337309c2d6c72566a3426994b6da443d7.tar.gz
rails-b8569b9337309c2d6c72566a3426994b6da443d7.tar.bz2
rails-b8569b9337309c2d6c72566a3426994b6da443d7.zip
Fix mysql to support duplicated column names
This will fix the [broken test](https://github.com/rails/rails/commit/4a2650836680f51490e999c3c8441a2f9adff96e) `test_with_limiting_with_custom_select`. The query's result was built in a hash with column name as key, if the result have a duplicated column name the last value was overriding the first one.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql_adapter.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
index c4dcba0501..760f1435eb 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -419,14 +419,19 @@ module ActiveRecord
if result
types = {}
+ fields = []
result.fetch_fields.each { |field|
+ field_name = field.name
+ fields << field_name
+
if field.decimals > 0
- types[field.name] = Fields::Decimal.new
+ types[field_name] = Fields::Decimal.new
else
- types[field.name] = Fields.find_type field
+ types[field_name] = Fields.find_type field
end
}
- result_set = ActiveRecord::Result.new(types.keys, result.to_a, types)
+
+ result_set = ActiveRecord::Result.new(fields, result.to_a, types)
result.free
else
result_set = ActiveRecord::Result.new([], [])