X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FAbstract%2FAST%2Fv1.pm;fp=lib%2FSQL%2FAbstract%2FAST%2Fv1.pm;h=054333083a7584176c48b7711e886ab768300a78;hb=39f7dc30da0d08a669cd702c0b50aeac6916fa4b;hp=53db579d14c835aeab40531660eb199ba142ed56;hpb=6a0089031c12a6af04b2ed79a1d88c950f12c98d;p=dbsrgits%2FSQL-Abstract-2.0-ish.git diff --git a/lib/SQL/Abstract/AST/v1.pm b/lib/SQL/Abstract/AST/v1.pm index 53db579..0543330 100644 --- a/lib/SQL/Abstract/AST/v1.pm +++ b/lib/SQL/Abstract/AST/v1.pm @@ -205,7 +205,9 @@ class SQL::Abstract::AST::v1 extends SQL::Abstract { if ($_->{-type} eq 'expr' && $_->{op} =~ /^(and|or)$/) { my $sub_prio = $SQL::Abstract::PRIO{$1}; - if ($sub_prio <= $prio) { + if ($sub_prio == $prio) { + # When the element below has same priority, i.e. 'or' as a child of + # 'or', dont produce extra brackets push @output, $self->_recurse_where($_); } else { push @output, '(' . $self->_recurse_where($_) . ')'; @@ -279,10 +281,13 @@ class SQL::Abstract::AST::v1 extends SQL::Abstract { croak "between requires 3 arguments: " . dump($ast) unless @values == 2; - return $self->_expr($field) . + # The brackets are to work round an issue with SQL::A::Test + return "(" . + $self->_expr($field) . $not . " BETWEEN " . - join(" AND ", map { $self->dispatch($_) } @values ); + join(" AND ", map { $self->dispatch($_) } @values ) . + ")"; } # 'constants' that are portable across DBs