diff options
Diffstat (limited to 'activerecord/lib/active_record/table_metadata.rb')
-rw-r--r-- | activerecord/lib/active_record/table_metadata.rb | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/activerecord/lib/active_record/table_metadata.rb b/activerecord/lib/active_record/table_metadata.rb index 4293c9704b..11e33e8dfe 100644 --- a/activerecord/lib/active_record/table_metadata.rb +++ b/activerecord/lib/active_record/table_metadata.rb @@ -34,7 +34,7 @@ module ActiveRecord association_klass = association.klass arel_table = association_klass.arel_table else - type_caster = ConnectionAdapterTypeCaster.new(klass.connection, table_name) + type_caster = TypeCaster::Connection.new(klass.connection, table_name) association_klass = nil arel_table = Arel::Table.new(table_name, type_caster: type_caster) end @@ -50,35 +50,4 @@ module ActiveRecord attr_reader :klass, :arel_table, :association end - - class ConnectionAdapterTypeCaster - def initialize(connection, table_name) - @connection = connection - @table_name = table_name - end - - def type_cast_for_database(attribute_name, value) - return value if value.is_a?(Arel::Nodes::BindParam) - type = type_for(attribute_name) - type.type_cast_for_database(value) - end - - protected - - attr_reader :connection, :table_name - - private - - def type_for(attribute_name) - if connection.schema_cache.table_exists?(table_name) - column_for(attribute_name).cast_type - else - Type::Value.new - end - end - - def column_for(attribute_name) - connection.schema_cache.columns_hash(table_name)[attribute_name.to_s] - end - end end |