aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-01-14 16:55:59 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2014-01-14 16:55:59 -0800
commit03118bc5afe99aaaf463a834d8a1ae16c918f6e8 (patch)
treec0aaf9e6cebfca656235247b5707bb5ac77a58f0 /activerecord
parent2fff094c9ad27e1027cdf66eda627ded3fb67c62 (diff)
downloadrails-03118bc5afe99aaaf463a834d8a1ae16c918f6e8.tar.gz
rails-03118bc5afe99aaaf463a834d8a1ae16c918f6e8.tar.bz2
rails-03118bc5afe99aaaf463a834d8a1ae16c918f6e8.zip
expliticly make STI column a bind value
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_association.rb13
1 files changed, 9 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 0dddf04fba..0333816abb 100644
--- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb
+++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb
@@ -61,15 +61,20 @@ module ActiveRecord
left.merge right
end
- if reflection.type
- constraint = constraint.and table[reflection.type].eq foreign_klass.base_class.name
- end
-
if rel && !rel.arel.constraints.empty?
bind_values.concat rel.bind_values
constraint = constraint.and rel.arel.constraints
end
+ if reflection.type
+ value = foreign_klass.base_class.name
+ column = klass.columns_hash[column.to_s]
+
+ substitute = klass.connection.substitute_at(column, bind_values.length)
+ bind_values.push [column, value]
+ constraint = constraint.and table[reflection.type].eq substitute
+ end
+
joins << table.create_join(table, table.create_on(constraint), join_type)
# The current table in this iteration becomes the foreign table in the next