mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-30 02:44:11 +00:00

This makes the parser more strict when handling SELECTs nested somewhere in the main statement: 1) instead of accepting SELECT anywhere in the expression where an operand was expected, we only accept it inside parens. (I've added a test for the currently supported syntax, <scalar subquery> in ANSI SQL terms) 2) instead of accepting any expression in the derived table context: `FROM ( ... )` - we only look for a SELECT subquery there. Due to #1, I had to swith the 'ansi' test from invoking the expression parser to the statement parser.
19 lines
545 B
Rust
19 lines
545 B
Rust
extern crate log;
|
|
extern crate sqlparser;
|
|
|
|
use sqlparser::dialect::AnsiSqlDialect;
|
|
use sqlparser::sqlast::*;
|
|
use sqlparser::sqlparser::*;
|
|
|
|
#[test]
|
|
fn parse_simple_select() {
|
|
let sql = String::from("SELECT id, fname, lname FROM customer WHERE id = 1");
|
|
let ast = Parser::parse_sql(&AnsiSqlDialect {}, sql).unwrap();
|
|
assert_eq!(1, ast.len());
|
|
match ast.first().unwrap() {
|
|
SQLStatement::SQLSelect(SQLSelect { projection, .. }) => {
|
|
assert_eq!(3, projection.len());
|
|
}
|
|
_ => assert!(false),
|
|
}
|
|
}
|