diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-10 12:41:05 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-10 12:42:02 -0700 |
commit | 134abedf198423e6b13d5582719bd9daabbbfa5a (patch) | |
tree | 77085dec64bb463987bbb846046c08105c0f690d /activerecord/lib/active_record/connection_adapters | |
parent | 7a09fc55c0d89f6a672c79fdd9787c51a85a06fc (diff) | |
download | rails-134abedf198423e6b13d5582719bd9daabbbfa5a.tar.gz rails-134abedf198423e6b13d5582719bd9daabbbfa5a.tar.bz2 rails-134abedf198423e6b13d5582719bd9daabbbfa5a.zip |
Stop passing a column to `quote` in `insert_fixture`
I'm planning on deprecating the column argument to mirror the
deprecation in [arel].
[arel]: https://github.com/rails/arel/commit/6160bfbda1d1781c3b08a33ec4955f170e95be11
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/quoting.rb | 10 |
2 files changed, 14 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index 59cdd8e98c..6e631ed9f7 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -285,11 +285,11 @@ module ActiveRecord def insert_fixture(fixture, table_name) columns = schema_cache.columns_hash(table_name) - key_list = [] - value_list = fixture.map do |name, value| - key_list << quote_column_name(name) - quote(value, columns[name]) + binds = fixture.map do |name, value| + [columns[name], value] end + key_list = fixture.keys.map { |name| quote_column_name(name) } + value_list = prepare_binds_for_database(binds).map { |_, value| quote(value) } execute "INSERT INTO #{quote_table_name(table_name)} (#{key_list.join(', ')}) VALUES (#{value_list.join(', ')})", 'Fixture Insert' end diff --git a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb index 143d7d9574..fb68ad17b2 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb @@ -92,6 +92,16 @@ module ActiveRecord private + def prepare_binds_for_database(binds) + binds.map do |column, value| + if column + column_name = column.name + value = column.cast_type.type_cast_for_database(value) + end + [column_name, value] + end + end + def types_which_need_no_typecasting [nil, Numeric, String] end |