Merging upstream version 17.4.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
f4a8b128b0
commit
bf82c6c1c0
78 changed files with 35859 additions and 34717 deletions
|
@ -1708,6 +1708,8 @@ class Parser(metaclass=_Parser):
|
|||
self._match(TokenType.TABLE)
|
||||
this = self._parse_table(schema=True)
|
||||
|
||||
returning = self._parse_returning()
|
||||
|
||||
return self.expression(
|
||||
exp.Insert,
|
||||
this=this,
|
||||
|
@ -1717,7 +1719,7 @@ class Parser(metaclass=_Parser):
|
|||
and self._parse_conjunction(),
|
||||
expression=self._parse_ddl_select(),
|
||||
conflict=self._parse_on_conflict(),
|
||||
returning=self._parse_returning(),
|
||||
returning=returning or self._parse_returning(),
|
||||
overwrite=overwrite,
|
||||
alternative=alternative,
|
||||
ignore=ignore,
|
||||
|
@ -1761,8 +1763,11 @@ class Parser(metaclass=_Parser):
|
|||
def _parse_returning(self) -> t.Optional[exp.Returning]:
|
||||
if not self._match(TokenType.RETURNING):
|
||||
return None
|
||||
|
||||
return self.expression(exp.Returning, expressions=self._parse_csv(self._parse_column))
|
||||
return self.expression(
|
||||
exp.Returning,
|
||||
expressions=self._parse_csv(self._parse_expression),
|
||||
into=self._match(TokenType.INTO) and self._parse_table_part(),
|
||||
)
|
||||
|
||||
def _parse_row(self) -> t.Optional[exp.RowFormatSerdeProperty | exp.RowFormatDelimitedProperty]:
|
||||
if not self._match(TokenType.FORMAT):
|
||||
|
@ -1824,25 +1829,30 @@ class Parser(metaclass=_Parser):
|
|||
if not self._match(TokenType.FROM, advance=False):
|
||||
tables = self._parse_csv(self._parse_table) or None
|
||||
|
||||
returning = self._parse_returning()
|
||||
|
||||
return self.expression(
|
||||
exp.Delete,
|
||||
tables=tables,
|
||||
this=self._match(TokenType.FROM) and self._parse_table(joins=True),
|
||||
using=self._match(TokenType.USING) and self._parse_table(joins=True),
|
||||
where=self._parse_where(),
|
||||
returning=self._parse_returning(),
|
||||
returning=returning or self._parse_returning(),
|
||||
limit=self._parse_limit(),
|
||||
)
|
||||
|
||||
def _parse_update(self) -> exp.Update:
|
||||
this = self._parse_table(alias_tokens=self.UPDATE_ALIAS_TOKENS)
|
||||
expressions = self._match(TokenType.SET) and self._parse_csv(self._parse_equality)
|
||||
returning = self._parse_returning()
|
||||
return self.expression(
|
||||
exp.Update,
|
||||
**{ # type: ignore
|
||||
"this": self._parse_table(alias_tokens=self.UPDATE_ALIAS_TOKENS),
|
||||
"expressions": self._match(TokenType.SET) and self._parse_csv(self._parse_equality),
|
||||
"this": this,
|
||||
"expressions": expressions,
|
||||
"from": self._parse_from(joins=True),
|
||||
"where": self._parse_where(),
|
||||
"returning": self._parse_returning(),
|
||||
"returning": returning or self._parse_returning(),
|
||||
"limit": self._parse_limit(),
|
||||
},
|
||||
)
|
||||
|
@ -1969,31 +1979,9 @@ class Parser(metaclass=_Parser):
|
|||
|
||||
self._match_r_paren()
|
||||
|
||||
alias = None
|
||||
|
||||
# Ensure "wrapped" tables are not parsed as Subqueries. The exception to this is when there's
|
||||
# an alias that can be applied to the parentheses, because that would shadow all wrapped table
|
||||
# names, and so we want to parse it as a Subquery to represent the inner scope appropriately.
|
||||
# Additionally, we want the node under the Subquery to be an actual query, so we will replace
|
||||
# the table reference with a star query that selects from it.
|
||||
if isinstance(this, exp.Table):
|
||||
alias = self._parse_table_alias()
|
||||
if not alias:
|
||||
this.set("wrapped", True)
|
||||
return this
|
||||
|
||||
this.set("wrapped", None)
|
||||
joins = this.args.pop("joins", None)
|
||||
this = this.replace(exp.select("*").from_(this.copy(), copy=False))
|
||||
this.set("joins", joins)
|
||||
|
||||
subquery = self._parse_subquery(this, parse_alias=parse_subquery_alias and not alias)
|
||||
if subquery and alias:
|
||||
subquery.set("alias", alias)
|
||||
|
||||
# We return early here so that the UNION isn't attached to the subquery by the
|
||||
# following call to _parse_set_operations, but instead becomes the parent node
|
||||
return subquery
|
||||
return self._parse_subquery(this, parse_alias=parse_subquery_alias)
|
||||
elif self._match(TokenType.VALUES):
|
||||
this = self.expression(
|
||||
exp.Values,
|
||||
|
@ -3086,7 +3074,13 @@ class Parser(metaclass=_Parser):
|
|||
if self._match_pair(TokenType.L_BRACKET, TokenType.R_BRACKET):
|
||||
this = exp.DataType(
|
||||
this=exp.DataType.Type.ARRAY,
|
||||
expressions=[exp.DataType.build(type_token.value, expressions=expressions)],
|
||||
expressions=[
|
||||
exp.DataType(
|
||||
this=exp.DataType.Type[type_token.value],
|
||||
expressions=expressions,
|
||||
nested=nested,
|
||||
)
|
||||
],
|
||||
nested=True,
|
||||
)
|
||||
|
||||
|
@ -3147,7 +3141,7 @@ class Parser(metaclass=_Parser):
|
|||
return value
|
||||
|
||||
return exp.DataType(
|
||||
this=exp.DataType.Type[type_token.value.upper()],
|
||||
this=exp.DataType.Type[type_token.value],
|
||||
expressions=expressions,
|
||||
nested=nested,
|
||||
values=values,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue