mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-25 06:59:15 +00:00

This requires Rust 1.31 (from last year) to build, but is otherwise compatible with the 2015-edition code.
19 lines
577 B
Rust
19 lines
577 B
Rust
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(SQLQuery {
|
|
body: SQLSetExpr::Select(SQLSelect { projection, .. }),
|
|
..
|
|
}) => {
|
|
assert_eq!(3, projection.len());
|
|
}
|
|
_ => assert!(false),
|
|
}
|
|
}
|