mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-14 12:05:00 +00:00

The `@@version` test is MS' dialect of SQL, it seems, so test it with
its own dialect.
Update the rules for identifiers in Postresql dialect per documentation,
while we're at it. The current identifier rules in Postgresql dialect
were introduced in this commit - as a copy of generic rules, it seems:
810cd8e6cf (diff-2808df0fba0aed85f9d35c167bd6a5f1L138)
38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
#![warn(clippy::all)]
|
|
|
|
use sqlparser::dialect::{GenericSqlDialect, MsSqlDialect};
|
|
use sqlparser::sqlast::*;
|
|
use sqlparser::test_utils::*;
|
|
|
|
#[test]
|
|
fn parse_mssql_identifiers() {
|
|
let sql = "SELECT @@version, _foo$123 FROM ##temp";
|
|
let select = ms_and_generic().verified_only_select(sql);
|
|
assert_eq!(
|
|
&ASTNode::SQLIdentifier("@@version".to_string()),
|
|
expr_from_projection(&select.projection[0]),
|
|
);
|
|
assert_eq!(
|
|
&ASTNode::SQLIdentifier("_foo$123".to_string()),
|
|
expr_from_projection(&select.projection[1]),
|
|
);
|
|
assert_eq!(2, select.projection.len());
|
|
match select.relation {
|
|
Some(TableFactor::Table { name, .. }) => {
|
|
assert_eq!("##temp".to_string(), name.to_string());
|
|
}
|
|
_ => unreachable!(),
|
|
};
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
fn ms() -> TestedDialects {
|
|
TestedDialects {
|
|
dialects: vec![Box::new(MsSqlDialect {})],
|
|
}
|
|
}
|
|
fn ms_and_generic() -> TestedDialects {
|
|
TestedDialects {
|
|
dialects: vec![Box::new(MsSqlDialect {}), Box::new(GenericSqlDialect {})],
|
|
}
|
|
}
|