Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

directly create the ARel AST

rather than allocating a new Relation, just make the AST directly
  • Loading branch information...
commit 3204bbf8798e3203faad59bf26c3a6b3cb3de4e6 1 parent e64a83c
@tenderlove tenderlove authored
View
10 activerecord/lib/active_record/associations/join_dependency/join_association.rb
@@ -52,18 +52,16 @@ def join_constraints(foreign_table, foreign_klass, node, join_type, tables, scop
end
end
- if reflection.type
- scope_chain_items <<
- ActiveRecord::Relation.create(klass, table)
- .where(reflection.type => foreign_klass.base_class.name)
- end
-
scope_chain_items.concat [klass.send(:build_default_scope)].compact
rel = scope_chain_items.inject(scope_chain_items.shift) do |left, right|
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?
constraint = constraint.and rel.arel.constraints
end
Please sign in to comment.
Something went wrong with that request. Please try again.