mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 06:18:17 +00:00
Remove the ansi-specific test file and update PG tests
- The ANSI dialect is now tested in `sqlparser_common.rs` - Some PG testcases are also parsed by the generic dialect successfully, so test that.
This commit is contained in:
parent
1347ca0825
commit
5047f2c02e
2 changed files with 4 additions and 36 deletions
|
@ -1,24 +0,0 @@
|
|||
#![warn(clippy::all)]
|
||||
|
||||
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 mut ast = Parser::parse_sql(&AnsiSqlDialect {}, sql).unwrap();
|
||||
assert_eq!(1, ast.len());
|
||||
match ast.pop().unwrap() {
|
||||
SQLStatement::SQLQuery(q) => match *q {
|
||||
SQLQuery {
|
||||
body: SQLSetExpr::Select(select),
|
||||
..
|
||||
} => {
|
||||
assert_eq!(3, select.projection.len());
|
||||
}
|
||||
_ => unreachable!(),
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
use sqlparser::dialect::{GenericSqlDialect, PostgreSqlDialect};
|
||||
use sqlparser::sqlast::*;
|
||||
use sqlparser::sqlparser::*;
|
||||
use sqlparser::test_utils::*;
|
||||
|
||||
#[test]
|
||||
|
@ -28,7 +27,7 @@ fn parse_create_table_with_defaults() {
|
|||
create_date date DEFAULT now()::text NOT NULL,
|
||||
last_update timestamp without time zone DEFAULT now() NOT NULL,
|
||||
active integer NOT NULL)";
|
||||
match one_statement_parses_to(sql, "") {
|
||||
match pg_and_generic().one_statement_parses_to(sql, "") {
|
||||
SQLStatement::SQLCreateTable {
|
||||
name,
|
||||
columns,
|
||||
|
@ -74,7 +73,7 @@ fn parse_create_table_from_pg_dump() {
|
|||
release_year public.year,
|
||||
active integer
|
||||
)";
|
||||
match one_statement_parses_to(sql, "") {
|
||||
match pg().one_statement_parses_to(sql, "") {
|
||||
SQLStatement::SQLCreateTable {
|
||||
name,
|
||||
columns,
|
||||
|
@ -135,7 +134,7 @@ fn parse_create_table_with_inherit() {
|
|||
value text[], \
|
||||
use_metric boolean DEFAULT true\
|
||||
)";
|
||||
match verified_stmt(sql) {
|
||||
match pg().verified_stmt(sql) {
|
||||
SQLStatement::SQLCreateTable {
|
||||
name,
|
||||
columns,
|
||||
|
@ -185,18 +184,11 @@ Kwara & Kogi
|
|||
PHP ₱ USD $
|
||||
\N Some other value
|
||||
\\."#;
|
||||
let ast = one_statement_parses_to(sql, "");
|
||||
let ast = pg_and_generic().one_statement_parses_to(sql, "");
|
||||
println!("{:#?}", ast);
|
||||
//assert_eq!(sql, ast.to_string());
|
||||
}
|
||||
|
||||
fn one_statement_parses_to(sql: &str, canonical: &str) -> SQLStatement {
|
||||
pg().one_statement_parses_to(sql, canonical)
|
||||
}
|
||||
fn verified_stmt(query: &str) -> SQLStatement {
|
||||
pg().verified_stmt(query)
|
||||
}
|
||||
|
||||
fn pg() -> TestedDialects {
|
||||
TestedDialects {
|
||||
dialects: vec![Box::new(PostgreSqlDialect {})],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue