diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-27 12:07:06 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-27 12:07:06 -0700 |
commit | 6c235dd95812a7c4e8123b6d34d6f3433805ee1c (patch) | |
tree | 9c148b9d42c13a88fe646494529d9f756e391405 /activerecord/lib/active_record/associations | |
parent | 102a5272c5944a6f715da8332d18e7e0380727d1 (diff) | |
download | rails-6c235dd95812a7c4e8123b6d34d6f3433805ee1c.tar.gz rails-6c235dd95812a7c4e8123b6d34d6f3433805ee1c.tar.bz2 rails-6c235dd95812a7c4e8123b6d34d6f3433805ee1c.zip |
Use an `Attribute` object to represent a bind value
The column is primarily used for type casting, which we're trying to
separate from the idea of a column. Since what we really need is the
combination of a name, type, and value, let's use the object that we
already have to represent that concept, rather than this tuple. No
consumers of the bind values have been changed, only the producers
(outside of tests which care too much about internals). This is
*finally* possible since the bind values are now produced from a
reasonable number of lcoations.
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency/join_association.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb index c1ef86a95b..3a184cee37 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -25,7 +25,7 @@ module ActiveRecord def join_constraints(foreign_table, foreign_klass, node, join_type, tables, scope_chain, chain) joins = [] - bind_values = [] + binds = [] tables = tables.reverse scope_chain_index = 0 @@ -66,7 +66,7 @@ module ActiveRecord end if rel && !rel.arel.constraints.empty? - bind_values.concat rel.bind_values + binds += rel.bound_attributes constraint = constraint.and rel.arel.constraints end @@ -75,7 +75,7 @@ module ActiveRecord column = klass.columns_hash[reflection.type.to_s] substitute = klass.connection.substitute_at(column) - bind_values.push [column, value] + binds << Attribute.with_cast_value(column.name, value, klass.type_for_attribute(column.name)) constraint = constraint.and table[reflection.type].eq substitute end @@ -85,7 +85,7 @@ module ActiveRecord foreign_table, foreign_klass = table, klass end - JoinInformation.new joins, bind_values + JoinInformation.new joins, binds end # Builds equality condition. |