mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-09 13:40:22 +00:00
parse SQLite pragma statement (#969)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
parent
2798b65b42
commit
8b2a248d7b
4 changed files with 92 additions and 0 deletions
|
@ -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";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue