diff options
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/nodes/join_source.rb | 4 | ||||
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/arel/nodes/join_source.rb b/lib/arel/nodes/join_source.rb index c57ad0e930..da828cf9ee 100644 --- a/lib/arel/nodes/join_source.rb +++ b/lib/arel/nodes/join_source.rb @@ -9,6 +9,10 @@ module Arel def initialize single_source, joinop = [] super end + + def empty? + !left && right.empty? + end end end end diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 8aec4cb147..ec62f4fb89 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -142,7 +142,7 @@ key on UpdateManager using UpdateManager#key= (visit(o.top) if o.top), (visit(o.set_quantifier) if o.set_quantifier), ("#{o.projections.map { |x| visit x }.join ', '}" unless o.projections.empty?), - (visit(o.source) if o.source), + ("FROM #{visit(o.source)}" if o.source && !o.source.empty?), ("WHERE #{o.wheres.map { |x| visit x }.join ' AND ' }" unless o.wheres.empty?), ("GROUP BY #{o.groups.map { |x| visit x }.join ', ' }" unless o.groups.empty?), (visit(o.having) if o.having), @@ -288,10 +288,7 @@ key on UpdateManager using UpdateManager#key= end def visit_Arel_Nodes_JoinSource o - return unless o.left || !o.right.empty? - [ - "FROM", (visit(o.left) if o.left), o.right.map { |j| visit j }.join(' ') ].compact.join ' ' |