feat: Support CLOSE (cursors) (#515)

This commit is contained in:
Dmitry Patsura 2022-06-06 23:09:17 +03:00 committed by GitHub
parent 3f1c6426f0
commit d361c3a3a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 0 deletions

View file

@ -20,6 +20,7 @@
#[macro_use]
mod test_utils;
use matches::assert_matches;
use sqlparser::ast::*;
use sqlparser::dialect::{
@ -28,6 +29,7 @@ use sqlparser::dialect::{
};
use sqlparser::keywords::ALL_KEYWORDS;
use sqlparser::parser::{Parser, ParserError};
use test_utils::{
all_dialects, expr_from_projection, join, number, only, table, table_alias, TestedDialects,
};
@ -4944,3 +4946,23 @@ fn parse_discard() {
_ => unreachable!(),
}
}
#[test]
fn parse_cursor() {
let sql = r#"CLOSE my_cursor"#;
match verified_stmt(sql) {
Statement::Close { cursor } => assert_eq!(
cursor,
CloseCursor::Specific {
name: Ident::new("my_cursor"),
}
),
_ => unreachable!(),
}
let sql = r#"CLOSE ALL"#;
match verified_stmt(sql) {
Statement::Close { cursor } => assert_eq!(cursor, CloseCursor::All),
_ => unreachable!(),
}
}