Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make type_condition return Arel predicate and not a string condition

  • Loading branch information...
commit 2d0bc08a7e1a0ecee577674deba2c0a17fe665e4 1 parent 99dd107
Pratik lifo authored
2  activerecord/lib/active_record/associations/through_association_scope.rb
View
@@ -144,7 +144,7 @@ def build_through_conditions
end
def build_sti_condition
- @reflection.through_reflection.klass.send(:type_condition)
+ @reflection.through_reflection.klass.send(:type_condition).to_sql
end
alias_method :sql_conditions, :conditions
8 activerecord/lib/active_record/base.rb
View
@@ -1622,14 +1622,12 @@ def array_of_strings?(o)
o.is_a?(Array) && o.all?{|obj| obj.is_a?(String)}
end
- def type_condition(table_alias = nil)
- table = Arel::Table.new(table_name, :engine => active_relation_engine, :as => table_alias)
-
- sti_column = table[inheritance_column]
+ def type_condition
+ sti_column = active_relation_table[inheritance_column]
condition = sti_column.eq(sti_name)
subclasses.each{|subclass| condition = condition.or(sti_column.eq(subclass.sti_name)) }
- condition.to_sql
+ condition
end
# Guesses the table name, but does not decorate it with prefix and suffix information.
Please sign in to comment.
Something went wrong with that request. Please try again.