Skip to content

Commit 7a9793b

Browse files
Allow semi-colon at the end of UNCACHE statement (#1320)
1 parent f3d2f78 commit 7a9793b

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

src/parser/mod.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3611,21 +3611,13 @@ impl<'a> Parser<'a> {
36113611

36123612
/// Parse a UNCACHE TABLE statement
36133613
pub fn parse_uncache_table(&mut self) -> Result<Statement, ParserError> {
3614-
let has_table = self.parse_keyword(Keyword::TABLE);
3615-
if has_table {
3616-
let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]);
3617-
let table_name = self.parse_object_name(false)?;
3618-
if self.peek_token().token == Token::EOF {
3619-
Ok(Statement::UNCache {
3620-
table_name,
3621-
if_exists,
3622-
})
3623-
} else {
3624-
self.expected("an `EOF`", self.peek_token())
3625-
}
3626-
} else {
3627-
self.expected("a `TABLE` keyword", self.peek_token())
3628-
}
3614+
self.expect_keyword(Keyword::TABLE)?;
3615+
let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]);
3616+
let table_name = self.parse_object_name(false)?;
3617+
Ok(Statement::UNCache {
3618+
table_name,
3619+
if_exists,
3620+
})
36293621
}
36303622

36313623
/// SQLite-specific `CREATE VIRTUAL TABLE`

tests/sqlparser_common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8465,19 +8465,19 @@ fn parse_uncache_table() {
84658465

84668466
let res = parse_sql_statements("UNCACHE TABLE 'table_name' foo");
84678467
assert_eq!(
8468-
ParserError::ParserError("Expected: an `EOF`, found: foo".to_string()),
8468+
ParserError::ParserError("Expected: end of statement, found: foo".to_string()),
84698469
res.unwrap_err()
84708470
);
84718471

84728472
let res = parse_sql_statements("UNCACHE 'table_name' foo");
84738473
assert_eq!(
8474-
ParserError::ParserError("Expected: a `TABLE` keyword, found: 'table_name'".to_string()),
8474+
ParserError::ParserError("Expected: TABLE, found: 'table_name'".to_string()),
84758475
res.unwrap_err()
84768476
);
84778477

84788478
let res = parse_sql_statements("UNCACHE IF EXISTS 'table_name' foo");
84798479
assert_eq!(
8480-
ParserError::ParserError("Expected: a `TABLE` keyword, found: IF".to_string()),
8480+
ParserError::ParserError("Expected: TABLE, found: IF".to_string()),
84818481
res.unwrap_err()
84828482
);
84838483
}

0 commit comments

Comments
 (0)