handle nested rather than unrolled joins
Matt S Trout [Mon, 16 Apr 2012 14:03:00 +0000 (14:03 +0000)]
lib/Data/Query/Renderer/SQL/Naive.pm

index 3d264e7..8531a2f 100644 (file)
@@ -337,8 +337,10 @@ sub _render_join {
       ','
     }
   };
+  my $rhs = $self->_render($right);
   [
-    $self->_render($left), $join, $self->_render($right),
+    $self->_render($left), $join,
+    ($right->{type} eq DQ_JOIN ? ('(', $rhs, ')') : $rhs),
     ($dq->{on}
       ? ($self->_format_keyword('ON'), $self->_render($dq->{on}))
       : ())