mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-03 05:32:17 +00:00
Enable dialect specific behaviours in the parser (#254)
* Change `Parser { ... }` to store the dialect used: `Parser<'a> { ... dialect: &'a dyn Dialect }` Thanks to @c7hm4r for the initial version of this submitted as part of https://github.com/ballista-compute/sqlparser-rs/pull/170 * Introduce `dialect_of!(parser is SQLiteDialect | GenericDialect)` helper to branch on the dialect's type * Use the new functionality to make `AUTO_INCREMENT` and `AUTOINCREMENT` parsing dialect-dependent. Co-authored-by: Christoph Müller <pmzqxfmn@runbox.com> Co-authored-by: Nickolay Ponomarev <asqueella@gmail.com>
This commit is contained in:
parent
3871bbc5ee
commit
1b46e82eec
5 changed files with 85 additions and 17 deletions
|
@ -22,7 +22,7 @@ use matches::assert_matches;
|
|||
|
||||
use sqlparser::ast::*;
|
||||
use sqlparser::dialect::keywords::ALL_KEYWORDS;
|
||||
use sqlparser::parser::{Parser, ParserError};
|
||||
use sqlparser::parser::ParserError;
|
||||
use sqlparser::test_utils::{all_dialects, expr_from_projection, number, only};
|
||||
|
||||
#[test]
|
||||
|
@ -147,13 +147,14 @@ fn parse_update() {
|
|||
|
||||
#[test]
|
||||
fn parse_invalid_table_name() {
|
||||
let ast = all_dialects().run_parser_method("db.public..customer", Parser::parse_object_name);
|
||||
let ast = all_dialects()
|
||||
.run_parser_method("db.public..customer", |parser| parser.parse_object_name());
|
||||
assert!(ast.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_no_table_name() {
|
||||
let ast = all_dialects().run_parser_method("", Parser::parse_object_name);
|
||||
let ast = all_dialects().run_parser_method("", |parser| parser.parse_object_name());
|
||||
assert!(ast.is_err());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue