mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-31 11:17:23 +00:00
[parser] Return error instead of panic (#316)
* [parser] return error instead of panic * Fix clippy warning * Fix cargo fmt warning
This commit is contained in:
parent
35ef0eee38
commit
56e50dccd4
3 changed files with 16 additions and 7 deletions
|
@ -24,7 +24,7 @@ use test_utils::{all_dialects, expr_from_projection, join, number, only, table,
|
|||
|
||||
use matches::assert_matches;
|
||||
use sqlparser::ast::*;
|
||||
use sqlparser::dialect::{keywords::ALL_KEYWORDS, SQLiteDialect};
|
||||
use sqlparser::dialect::{keywords::ALL_KEYWORDS, GenericDialect, SQLiteDialect};
|
||||
use sqlparser::parser::{Parser, ParserError};
|
||||
|
||||
#[test]
|
||||
|
@ -109,7 +109,7 @@ fn parse_insert_sqlite() {
|
|||
.unwrap()
|
||||
{
|
||||
Statement::Insert { or, .. } => assert_eq!(or, expected_action),
|
||||
_ => panic!(sql.to_string()),
|
||||
_ => panic!("{}", sql.to_string()),
|
||||
};
|
||||
|
||||
let sql = "INSERT INTO test_table(id) VALUES(1)";
|
||||
|
@ -358,6 +358,15 @@ fn test_eof_after_as() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_no_infix_error() {
|
||||
let res = Parser::parse_sql(&GenericDialect {}, "ASSERT-URA<<");
|
||||
assert_eq!(
|
||||
ParserError::ParserError("No infix parser for token ShiftLeft".to_string()),
|
||||
res.unwrap_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_select_count_wildcard() {
|
||||
let sql = "SELECT COUNT(*) FROM customer";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue