aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index df41f756ce..705bf21eae 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -296,7 +296,12 @@ module ActiveRecord
if Arel::Table === relation
relation.from(ast || relation)
else
- relation.join(custom_joins)
+ if relation.froms.length > 0 && ast
+ ast.left = relation.froms.first
+ relation.from ast
+ else
+ relation.join(custom_joins)
+ end
end
end