- Fix insufficient parenthesis unroll during operator comparison
- 'ORDER BY foo' and 'ORDER BY foo ASC' are now considered equal
by default (with a switch to reenable old behavior when necessary)
+ - Change parser to not eagerly slurp RHS expressions it doesn't recognize
revision 1.73 2012-07-10
----------------------------
}
# we're now in "unknown token" land - start eating tokens until
- # we see something familiar
+ # we see something familiar, OR in the case of RHS (binop) stop
+ # after the first token
else {
my @lits = [ -LITERAL => [$token] ];
- while (@$tokens and $tokens->[0] !~ $all_std_keywords_re) {
- push @lits, [ -LITERAL => [ shift @$tokens ] ];
- }
+ unless ( $state == PARSE_RHS ) {
+ while (@$tokens and $tokens->[0] !~ $all_std_keywords_re) {
+ push @lits, [ -LITERAL => [ shift @$tokens ] ];
+ }
+ }
if (@left == 1) {
unshift @lits, pop @left;
}
if (@$tokens) {
- # asc/desc
+
+ # deal with post-fix operators (asc/desc)
if ($tokens->[0] =~ $asc_desc_re) {
@left = [ ('-' . uc (shift @$tokens)) => [ @left ] ];
}
+
+ return @left if $state == PARSE_RHS and $left[-1][0] eq '-LITERAL';
}
}
}
]
], 'Crazy ORDER BY parsed correctly');
-
-is_deeply($sqlat->parse("SELECT * * FROM (SELECT *, FROM foobar baz buzz) foo bar WHERE NOT NOT NOT EXISTS (SELECT 'cr,ap') AND foo.a = ? and not (foo.b LIKE 'station') and x = y and a = b and GROUP BY , ORDER BY x x1 x2 y asc, max(y) desc x z desc"), [
+is_deeply( $sqlat->parse("META SELECT * * FROM (SELECT *, FROM foobar baz buzz) foo bar WHERE NOT NOT NOT EXISTS (SELECT 'cr,ap') AND foo.a = ? STUFF and not (foo.b LIKE 'station') and x = y and a = b and GROUP BY , ORDER BY x x1 x2 y asc, max(y) desc x z desc"), [
+ [
+ "-LITERAL",
+ [
+ "META"
+ ]
+ ],
[
"SELECT",
[
]
],
[
- "-PLACEHOLDER",
+ "-MISC",
[
- "?"
- ]
+ [
+ "-PLACEHOLDER",
+ [
+ "?"
+ ]
+ ],
+ [
+ "-LITERAL",
+ [
+ "STUFF"
+ ]
+ ]
+ ],
]
]
],
"-MISC",
[
[
- "-DESC",
+ "-MISC",
[
[
- "-PAREN",
+ "-DESC",
[
[
- "-LITERAL",
+ "-PAREN",
[
- "y"
+ [
+ "-LITERAL",
+ [
+ "y"
+ ]
+ ]
]
]
]
- ]
- ]
- ],
- [
- "-LITERAL",
- [
- "x"
+ ],
+ [
+ "-LITERAL",
+ [
+ "x"
+ ]
+ ],
]
],
[