- Fix parsing of binary ops to correctly take up only a single LHS
element, instead of gobbling up the entire parse-to-date
+ - Explicitly handle ROW_NUMBER() OVER as the snowflake-operator it is
revision 1.77 2014-01-17
----------------------------
$changes++;
}
- # if the parent operator explicitly allows it nuke the parenthesis
- if ( $ast->[0] =~ $unrollable_ops_re ) {
+ # if the parent operator explicitly allows it AND the child isn't a subselect
+ # nuke the parenthesis
+ if ($ast->[0] =~ $unrollable_ops_re and $child->[1][0][0] ne 'SELECT') {
push @children, @{$child->[1]};
$changes++;
}
# a construct of ... ( somefunc ( ... ) ) ... can safely lose the outer parens
# except for the case of ( NOT ( ... ) ) which has already been handled earlier
+ # and except for the case of RNO, where the double are explicit syntax
elsif (
+ $ast->[0] ne 'ROW_NUMBER() OVER'
+ and
@{$child->[1]} == 1
and
@{$child->[1][0][1]} == 1
"SELECT * FROM foo WHERE foo.a @@ to_tsquery('word')",
"SELECT * FROM foo ORDER BY name + ?, [me].[id]",
"SELECT foo AS bar FROM baz ORDER BY x + ? DESC, baz.g",
+ "SELECT [me].[id], ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [rno__row__index] FROM ( SELECT [me].[id] FROM [LogParents] [me]) [me]",
# deliberate batshit insanity
"SELECT foo FROM bar WHERE > 12",
);