Support multiple-table DELETE syntax (#855)

This commit is contained in:
AviRaboah 2023-04-27 18:41:20 +03:00 committed by GitHub
parent 5ecf633e31
commit f72e2ec382
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 131 additions and 26 deletions

View file

@ -4813,10 +4813,17 @@ impl<'a> Parser<'a> {
}
pub fn parse_delete(&mut self) -> Result<Statement, ParserError> {
self.expect_keyword(Keyword::FROM)?;
let table_name = self.parse_table_factor()?;
let tables = if !self.parse_keyword(Keyword::FROM) {
let tables = self.parse_comma_separated(Parser::parse_object_name)?;
self.expect_keyword(Keyword::FROM)?;
tables
} else {
vec![]
};
let from = self.parse_comma_separated(Parser::parse_table_and_joins)?;
let using = if self.parse_keyword(Keyword::USING) {
Some(self.parse_table_factor()?)
Some(self.parse_comma_separated(Parser::parse_table_and_joins)?)
} else {
None
};
@ -4833,7 +4840,8 @@ impl<'a> Parser<'a> {
};
Ok(Statement::Delete {
table_name,
tables,
from,
using,
selection,
returning,