our $tb = __PACKAGE__->builder;
# Parser states for _recurse_parse()
-use constant {
- PARSE_TOP_LEVEL => 0,
- PARSE_IN_EXPR => 1,
- PARSE_IN_PARENS => 2,
-};
+use constant PARSE_TOP_LEVEL => 0;
+use constant PARSE_IN_EXPR => 1;
+use constant PARSE_IN_PARENS => 2;
# These SQL keywords always signal end of the current expression (except inside
# of a parenthesized subexpression).
my ($left, $right) = @_;
# ignore top-level parentheses
- while ($left->[0] eq 'PAREN') {$left = $left->[1] }
- while ($right->[0] eq 'PAREN') {$right = $right->[1]}
+ while ($left->[0] and $left->[0] eq 'PAREN') {$left = $left->[1] }
+ while ($right->[0] and $right->[0] eq 'PAREN') {$right = $right->[1]}
+ # if both are undef i.e. ()
+ if (not grep { defined $_ } ($left->[0], $right->[0]) ) {
+ return 1;
+ }
# if operators are different
- if ($left->[0] ne $right->[0]) {
+ elsif ($left->[0] ne $right->[0]) {
$sql_differ = sprintf "OP [$left->[0]] != [$right->[0]] in\nleft: %s\nright: %s\n",
unparse($left),
unparse($right);