'SAVEPOINT',
'RELEASE \s+ SAVEPOINT',
'RETURNING',
- 'ROW_NUMBER \s* \( \s* \) \s+ OVER',
);
my $expr_start_re = join ("\n\t|\n", @expression_start_keywords );
;
$binary_op_re = qr/$binary_op_re/x;
-my $unary_op_re = '(?: NOT \s+ EXISTS | NOT )';
+my $rno_re = qr/ROW_NUMBER \s* \( \s* \) \s+ OVER/ix;
+
+my $unary_op_re = 'NOT \s+ EXISTS | NOT | ' . $rno_re;
$unary_op_re = join "\n\t|\n",
"$op_look_behind (?i: $unary_op_re ) $op_look_ahead",
;
# unary op keywords
elsif ( $token =~ $unary_op_re ) {
my $op = uc $token;
+
+ # normalize RNO explicitly
+ $op = 'ROW_NUMBER() OVER' if $op =~ /^$rno_re$/;
+
my @right = $self->_recurse_parse ($tokens, PARSE_RHS);
push @left, [ $op => \@right ];
]
]);
+is_deeply($sqlat->parse("SELECT [me].[id], ROW_NUMBER ( ) OVER (ORDER BY (SELECT 1)) AS [rno__row__index] FROM bar"), [
+ [
+ "SELECT",
+ [
+ [
+ "-LIST",
+ [
+ [
+ "-LITERAL",
+ [
+ "[me].[id]"
+ ]
+ ],
+ [
+ "AS",
+ [
+ [
+ "ROW_NUMBER() OVER",
+ [
+ [
+ "-PAREN",
+ [
+ [
+ "ORDER BY",
+ [
+ [
+ "-PAREN",
+ [
+ [
+ "SELECT",
+ [
+ [
+ "-LITERAL",
+ [
+ 1
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ],
+ [
+ "-LITERAL",
+ [
+ "[rno__row__index]"
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ],
+ [
+ "FROM",
+ [
+ [
+ "-LITERAL",
+ [
+ "bar"
+ ]
+ ]
+ ]
+ ]
+]);
+
is_deeply($sqlat->parse("SELECT x, y FROM foo WHERE x IN (?, ?, ?, ?)"), [
[