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($_) . ')';
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
{ -type => 'expr', op => 'and', args => $cols }
]
}
-), "me.name = ? OR me.id > ? AND me.name = ?",
+), "me.name = ? OR (me.id > ? AND me.name = ?)",
"expr clause (inner and)";
is $sqla->dispatch(
{ -type => 'value', value => 599 },
],
}
-), "me.id BETWEEN ? AND ?",
+), "(me.id BETWEEN ? AND ?)",
"between";