diff --git a/src/lib.rs b/src/lib.rs index 5b232457..f9edf178 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,7 +32,7 @@ //! //! println!("AST: {:?}", ast); //! ``` -#![warn(clippy::all)] +#![allow(clippy::upper_case_acronyms)] pub mod ast; #[macro_use] diff --git a/src/parser.rs b/src/parser.rs index 863fc66d..75d603a7 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -883,7 +883,7 @@ impl<'a> Parser<'a> { } } // Can only happen if `get_next_precedence` got out of sync with this function - _ => panic!("No infix parser for token {:?}", tok), + _ => parser_err!(format!("No infix parser for token {:?}", tok)), } } else if Token::DoubleColon == tok { self.parse_pg_cast(expr) @@ -897,7 +897,7 @@ impl<'a> Parser<'a> { self.parse_map_access(expr) } else { // Can only happen if `get_next_precedence` got out of sync with this function - panic!("No infix parser for token {:?}", tok) + parser_err!(format!("No infix parser for token {:?}", tok)) } } @@ -2202,8 +2202,8 @@ impl<'a> Parser<'a> { Ok(Query { with, body, - limit, order_by, + limit, offset, fetch, }) @@ -2414,8 +2414,8 @@ impl<'a> Parser<'a> { top, projection, from, - selection, lateral_views, + selection, group_by, cluster_by, distribute_by, diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs index e43bd12c..bbb9bdc2 100644 --- a/tests/sqlparser_common.rs +++ b/tests/sqlparser_common.rs @@ -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";