aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-12-26 16:17:01 -0700
committerSean Griffin <sean@thoughtbot.com>2014-12-26 16:17:01 -0700
commit09369726346e44ccb6cbe9d020094e734669f957 (patch)
tree548d3c76d27edb9c98c41b7c6ebef01638920992
parentb98668decb9712f26118de57623fd15d7d28646d (diff)
downloadrails-09369726346e44ccb6cbe9d020094e734669f957.tar.gz
rails-09369726346e44ccb6cbe9d020094e734669f957.tar.bz2
rails-09369726346e44ccb6cbe9d020094e734669f957.zip
We don't need to perform type casting on the STI condition
We will always have the correct type for this query, so no casting is needed. We inform Arel that we already have the right type by wrapping it in an `Arel::Nodes::Quoted` (which we will no longer need to do in Rails 5.1)
-rw-r--r--activerecord/lib/active_record/inheritance.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb
index b91e9ac137..8a532402ba 100644
--- a/activerecord/lib/active_record/inheritance.rb
+++ b/activerecord/lib/active_record/inheritance.rb
@@ -193,6 +193,7 @@ module ActiveRecord
def type_condition(table = arel_table)
sti_column = table[inheritance_column]
sti_names = ([self] + descendants).map(&:sti_name)
+ sti_names.map! { |v| Arel::Nodes::Quoted.new(v) } # FIXME: Remove this when type casting in Arel is removed (5.1)
sti_column.in(sti_names)
end