Skip to content

Commit 1b91530

Browse files
Merge branch 'main' into drop-operator2
2 parents 182c971 + 2b8e99c commit 1b91530

File tree

5 files changed

+418
-47
lines changed

5 files changed

+418
-47
lines changed

src/ast/mod.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4071,6 +4071,8 @@ pub enum Statement {
40714071
/// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#merge_statement)
40724072
/// [MSSQL](https://learn.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql?view=sql-server-ver16)
40734073
Merge {
4074+
/// The `MERGE` token that starts the statement.
4075+
merge_token: AttachedToken,
40744076
/// optional INTO keyword
40754077
into: bool,
40764078
/// Specifies the table to merge
@@ -4095,7 +4097,6 @@ pub enum Statement {
40954097
/// Table flag
40964098
table_flag: Option<ObjectName>,
40974099
/// Table name
4098-
40994100
#[cfg_attr(feature = "visitor", visit(with = "visit_relation"))]
41004101
table_name: ObjectName,
41014102
has_as: bool,
@@ -5496,6 +5497,7 @@ impl fmt::Display for Statement {
54965497
write!(f, "RELEASE SAVEPOINT {name}")
54975498
}
54985499
Statement::Merge {
5500+
merge_token: _,
54995501
into,
55005502
table,
55015503
source,
@@ -8628,6 +8630,8 @@ impl Display for MergeInsertKind {
86288630
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
86298631
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
86308632
pub struct MergeInsertExpr {
8633+
/// The `INSERT` token that starts the sub-expression.
8634+
pub insert_token: AttachedToken,
86318635
/// Columns (if any) specified by the insert.
86328636
///
86338637
/// Example:
@@ -8636,6 +8640,8 @@ pub struct MergeInsertExpr {
86368640
/// INSERT (product, quantity) ROW
86378641
/// ```
86388642
pub columns: Vec<Ident>,
8643+
/// The token, `[VALUES | ROW]` starting `kind`.
8644+
pub kind_token: AttachedToken,
86398645
/// The insert type used by the statement.
86408646
pub kind: MergeInsertKind,
86418647
}
@@ -8675,9 +8681,16 @@ pub enum MergeAction {
86758681
/// ```sql
86768682
/// UPDATE SET quantity = T.quantity + S.quantity
86778683
/// ```
8678-
Update { assignments: Vec<Assignment> },
8684+
Update {
8685+
/// The `UPDATE` token that starts the sub-expression.
8686+
update_token: AttachedToken,
8687+
assignments: Vec<Assignment>,
8688+
},
86798689
/// A plain `DELETE` clause
8680-
Delete,
8690+
Delete {
8691+
/// The `DELETE` token that starts the sub-expression.
8692+
delete_token: AttachedToken,
8693+
},
86818694
}
86828695

86838696
impl Display for MergeAction {
@@ -8686,10 +8699,10 @@ impl Display for MergeAction {
86868699
MergeAction::Insert(insert) => {
86878700
write!(f, "INSERT {insert}")
86888701
}
8689-
MergeAction::Update { assignments } => {
8702+
MergeAction::Update { assignments, .. } => {
86908703
write!(f, "UPDATE SET {}", display_comma_separated(assignments))
86918704
}
8692-
MergeAction::Delete => {
8705+
MergeAction::Delete { .. } => {
86938706
write!(f, "DELETE")
86948707
}
86958708
}
@@ -8708,6 +8721,8 @@ impl Display for MergeAction {
87088721
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
87098722
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
87108723
pub struct MergeClause {
8724+
/// The `WHEN` token that starts the sub-expression.
8725+
pub when_token: AttachedToken,
87118726
pub clause_kind: MergeClauseKind,
87128727
pub predicate: Option<Expr>,
87138728
pub action: MergeAction,
@@ -8716,6 +8731,7 @@ pub struct MergeClause {
87168731
impl Display for MergeClause {
87178732
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
87188733
let MergeClause {
8734+
when_token: _,
87198735
clause_kind,
87208736
predicate,
87218737
action,
@@ -8739,10 +8755,12 @@ impl Display for MergeClause {
87398755
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
87408756
pub enum OutputClause {
87418757
Output {
8758+
output_token: AttachedToken,
87428759
select_items: Vec<SelectItem>,
87438760
into_table: Option<SelectInto>,
87448761
},
87458762
Returning {
8763+
returning_token: AttachedToken,
87468764
select_items: Vec<SelectItem>,
87478765
},
87488766
}
@@ -8751,6 +8769,7 @@ impl fmt::Display for OutputClause {
87518769
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
87528770
match self {
87538771
OutputClause::Output {
8772+
output_token: _,
87548773
select_items,
87558774
into_table,
87568775
} => {
@@ -8762,7 +8781,10 @@ impl fmt::Display for OutputClause {
87628781
}
87638782
Ok(())
87648783
}
8765-
OutputClause::Returning { select_items } => {
8784+
OutputClause::Returning {
8785+
returning_token: _,
8786+
select_items,
8787+
} => {
87668788
f.write_str("RETURNING ")?;
87678789
display_comma_separated(select_items).fmt(f)
87688790
}

0 commit comments

Comments
 (0)