feat: MERGE statements: add RETURNING and OUTPUT without INTO (#2011)
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run

This commit is contained in:
Ophir LOJKINE 2025-08-22 12:32:09 +02:00 committed by GitHub
parent 5d5c90c77f
commit 376f47e3d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 98 additions and 25 deletions

View file

@ -9107,24 +9107,36 @@ impl Display for MergeClause {
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub struct OutputClause {
pub select_items: Vec<SelectItem>,
pub into_table: SelectInto,
pub enum OutputClause {
Output {
select_items: Vec<SelectItem>,
into_table: Option<SelectInto>,
},
Returning {
select_items: Vec<SelectItem>,
},
}
impl fmt::Display for OutputClause {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let OutputClause {
select_items,
into_table,
} = self;
write!(
f,
"OUTPUT {} {}",
display_comma_separated(select_items),
into_table
)
match self {
OutputClause::Output {
select_items,
into_table,
} => {
f.write_str("OUTPUT ")?;
display_comma_separated(select_items).fmt(f)?;
if let Some(into_table) = into_table {
f.write_str(" ")?;
into_table.fmt(f)?;
}
Ok(())
}
OutputClause::Returning { select_items } => {
f.write_str("RETURNING ")?;
display_comma_separated(select_items).fmt(f)
}
}
}
}