Skip to content

Commit 04d30da

Browse files
committed
There is no need to create QueryAttribute to just type cast a value
1 parent 8976507 commit 04d30da

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,7 @@ def build_fixture_sql(fixtures, table_name)
427427
columns.map do |name, column|
428428
if fixture.key?(name)
429429
type = lookup_cast_type_from_column(column)
430-
bind = Relation::QueryAttribute.new(name, fixture[name], type)
431-
with_yaml_fallback(bind.value_for_database)
430+
with_yaml_fallback(type.serialize(fixture[name]))
432431
else
433432
default_insert_value(column)
434433
end

activerecord/lib/active_record/insert_all.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ def values_list
128128
types = extract_types_from_columns_on(model.table_name, keys: keys)
129129

130130
values_list = insert_all.map_key_with_value do |key, value|
131-
bind = Relation::QueryAttribute.new(key, value, types[key])
132-
connection.with_yaml_fallback(bind.value_for_database)
131+
connection.with_yaml_fallback(types[key].serialize(value))
133132
end
134133

135134
Arel::InsertManager.new.create_values_list(values_list).to_sql

0 commit comments

Comments
 (0)