From 8eb536e7b487351d7485879d436e9d747520ed90 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Thu, 29 May 2014 06:55:44 -0700 Subject: Result sets never override a model's column type MySQL and PostgreSQL provide a column type override in order to properly type cast computed columns included in a result set. This should never override the known types of full fledged columns. In addition to messing up computed properties, this would have led to inconsistent behavior between a record created with `new`, and a record created with `last` on the mysql adapter in the following cases: - `tinyint(1)` with `emulate_booleans` set to `false` - `text`, `string`, `binary`, and `decimal` columns --- activerecord/lib/active_record/querying.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/querying.rb') diff --git a/activerecord/lib/active_record/querying.rb b/activerecord/lib/active_record/querying.rb index ef138c6f80..1fe54cea3f 100644 --- a/activerecord/lib/active_record/querying.rb +++ b/activerecord/lib/active_record/querying.rb @@ -40,7 +40,7 @@ module ActiveRecord column_types = {} if result_set.respond_to? :column_types - column_types = result_set.column_types + column_types = result_set.column_types.merge(columns_hash) else ActiveSupport::Deprecation.warn "the object returned from `select_all` must respond to `column_types`" end -- cgit v1.2.3