t8y2 commented on code in PR #2451:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2451#discussion_r4111668176
##########
tests/sqlparser_mssql.rs:
##########
@@ -2941,3 +2945,33 @@ fn parse_bracket_quoted_function_argument_name() {
}])
);
}
+
+#[test]
+fn parse_mssql_cursor_options() {
+ for (sql, expected_options) in [
+ (
+ "DECLARE local_cursor CURSOR LOCAL FOR SELECT name FROM
dbo.reports",
+ vec![MsSqlCursorOption::Local],
+ ),
+ (
+ "DECLARE fast_cursor CURSOR FAST_FORWARD FOR SELECT name FROM
dbo.reports",
+ vec![MsSqlCursorOption::FastForward],
+ ),
+ (
+ "DECLARE global_cursor CURSOR GLOBAL FAST_FORWARD FOR SELECT name
FROM dbo.reports",
+ vec![MsSqlCursorOption::Global, MsSqlCursorOption::FastForward],
+ ),
Review Comment:
Added this regression case in `619da03`, asserting the preserved option
order as `FastForward` followed by `Local`.
##########
src/parser/mod.rs:
##########
@@ -8159,6 +8165,21 @@ impl<'a> Parser<'a> {
})
}
+ fn parse_mssql_cursor_options(&mut self) -> Vec<MsSqlCursorOption> {
+ let mut options = vec![];
+
+ match self.parse_one_of_keywords(&[Keyword::LOCAL, Keyword::GLOBAL]) {
+ Some(Keyword::LOCAL) => options.push(MsSqlCursorOption::Local),
+ Some(Keyword::GLOBAL) => options.push(MsSqlCursorOption::Global),
+ _ => {}
+ }
+ if self.parse_keyword(Keyword::FAST_FORWARD) {
+ options.push(MsSqlCursorOption::FastForward);
+ }
+
+ options
Review Comment:
Addressed in `619da03`. `parse_mssql_cursor_options` now consumes the
supported options in a loop, so `LOCAL`, `GLOBAL`, and `FAST_FORWARD` are
accepted in source order. I also rebased the branch onto the latest `main`. All
exact-head checks are now passing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]