parse SQLite pragma statement (#969)

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
Ilya 2023-10-24 01:07:39 +03:00 committed by GitHub
parent 2798b65b42
commit 8b2a248d7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 92 additions and 0 deletions

View file

@ -24,6 +24,51 @@ use sqlparser::ast::*;
use sqlparser::dialect::{GenericDialect, SQLiteDialect};
use sqlparser::tokenizer::Token;
#[test]
fn pragma_no_value() {
let sql = "PRAGMA cache_size";
match sqlite_and_generic().verified_stmt(sql) {
Statement::Pragma {
name,
value: None,
is_eq: false,
} => {
assert_eq!("cache_size", name.to_string());
}
_ => unreachable!(),
}
}
#[test]
fn pragma_eq_style() {
let sql = "PRAGMA cache_size = 10";
match sqlite_and_generic().verified_stmt(sql) {
Statement::Pragma {
name,
value: Some(val),
is_eq: true,
} => {
assert_eq!("cache_size", name.to_string());
assert_eq!("10", val.to_string());
}
_ => unreachable!(),
}
}
#[test]
fn pragma_funciton_style() {
let sql = "PRAGMA cache_size(10)";
match sqlite_and_generic().verified_stmt(sql) {
Statement::Pragma {
name,
value: Some(val),
is_eq: false,
} => {
assert_eq!("cache_size", name.to_string());
assert_eq!("10", val.to_string());
}
_ => unreachable!(),
}
}
#[test]
fn parse_create_table_without_rowid() {
let sql = "CREATE TABLE t (a INT) WITHOUT ROWID";