From a9321ef4e100b4678f4ba6fd0ce2496ea8a63d41 Mon Sep 17 00:00:00 2001 From: LorrensP-2158466 Date: Sat, 22 Jun 2024 17:37:10 +0200 Subject: [PATCH 1/2] change tests --- tests/sqlparser_common.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs index 0149bad5d..314bb8724 100644 --- a/tests/sqlparser_common.rs +++ b/tests/sqlparser_common.rs @@ -8451,19 +8451,31 @@ fn parse_uncache_table() { let res = parse_sql_statements("UNCACHE TABLE 'table_name' foo"); assert_eq!( +<<<<<<< HEAD ParserError::ParserError("Expected: an `EOF`, found: foo".to_string()), +======= + ParserError::ParserError("Expected: end of statement, found: foo".to_string()), +>>>>>>> c2fb339 (change tests) res.unwrap_err() ); let res = parse_sql_statements("UNCACHE 'table_name' foo"); assert_eq!( +<<<<<<< HEAD ParserError::ParserError("Expected: a `TABLE` keyword, found: 'table_name'".to_string()), +======= + ParserError::ParserError("Expected: TABLE, found: 'table_name'".to_string()), +>>>>>>> c2fb339 (change tests) res.unwrap_err() ); let res = parse_sql_statements("UNCACHE IF EXISTS 'table_name' foo"); assert_eq!( +<<<<<<< HEAD ParserError::ParserError("Expected: a `TABLE` keyword, found: IF".to_string()), +======= + ParserError::ParserError("Expected: TABLE, found: IF".to_string()), +>>>>>>> c2fb339 (change tests) res.unwrap_err() ); } From d34eae9fb78a1dde7a592a24a3df980d44053170 Mon Sep 17 00:00:00 2001 From: LorrensP-2158466 Date: Sat, 22 Jun 2024 17:42:15 +0200 Subject: [PATCH 2/2] fix merge conflict --- src/parser/mod.rs | 22 +++++++--------------- tests/sqlparser_common.rs | 12 ------------ 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 27520a6c4..e365587d6 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -3611,21 +3611,13 @@ impl<'a> Parser<'a> { /// Parse a UNCACHE TABLE statement pub fn parse_uncache_table(&mut self) -> Result { - let has_table = self.parse_keyword(Keyword::TABLE); - if has_table { - let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]); - let table_name = self.parse_object_name(false)?; - if self.peek_token().token == Token::EOF { - Ok(Statement::UNCache { - table_name, - if_exists, - }) - } else { - self.expected("an `EOF`", self.peek_token()) - } - } else { - self.expected("a `TABLE` keyword", self.peek_token()) - } + self.expect_keyword(Keyword::TABLE)?; + let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]); + let table_name = self.parse_object_name(false)?; + Ok(Statement::UNCache { + table_name, + if_exists, + }) } /// SQLite-specific `CREATE VIRTUAL TABLE` diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs index 314bb8724..bcccde740 100644 --- a/tests/sqlparser_common.rs +++ b/tests/sqlparser_common.rs @@ -8451,31 +8451,19 @@ fn parse_uncache_table() { let res = parse_sql_statements("UNCACHE TABLE 'table_name' foo"); assert_eq!( -<<<<<<< HEAD - ParserError::ParserError("Expected: an `EOF`, found: foo".to_string()), -======= ParserError::ParserError("Expected: end of statement, found: foo".to_string()), ->>>>>>> c2fb339 (change tests) res.unwrap_err() ); let res = parse_sql_statements("UNCACHE 'table_name' foo"); assert_eq!( -<<<<<<< HEAD - ParserError::ParserError("Expected: a `TABLE` keyword, found: 'table_name'".to_string()), -======= ParserError::ParserError("Expected: TABLE, found: 'table_name'".to_string()), ->>>>>>> c2fb339 (change tests) res.unwrap_err() ); let res = parse_sql_statements("UNCACHE IF EXISTS 'table_name' foo"); assert_eq!( -<<<<<<< HEAD - ParserError::ParserError("Expected: a `TABLE` keyword, found: IF".to_string()), -======= ParserError::ParserError("Expected: TABLE, found: IF".to_string()), ->>>>>>> c2fb339 (change tests) res.unwrap_err() ); }