Skip to content

SET with a list of comma separated assignments #1757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 12, 2025
361 changes: 216 additions & 145 deletions src/ast/mod.rs

Large diffs are not rendered by default.

15 changes: 2 additions & 13 deletions src/ast/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,7 @@ impl Spanned for Values {
/// - [Statement::Fetch]
/// - [Statement::Flush]
/// - [Statement::Discard]
/// - [Statement::SetRole]
/// - [Statement::SetVariable]
/// - [Statement::SetTimeZone]
/// - [Statement::SetNames]
/// - [Statement::SetNamesDefault]
/// - [Statement::Set]
/// - [Statement::ShowFunctions]
/// - [Statement::ShowVariable]
/// - [Statement::ShowStatus]
Expand All @@ -243,7 +239,6 @@ impl Spanned for Values {
/// - [Statement::ShowTables]
/// - [Statement::ShowCollation]
/// - [Statement::StartTransaction]
/// - [Statement::SetTransaction]
/// - [Statement::Comment]
/// - [Statement::Commit]
/// - [Statement::Rollback]
Expand Down Expand Up @@ -444,11 +439,7 @@ impl Spanned for Statement {
Statement::Fetch { .. } => Span::empty(),
Statement::Flush { .. } => Span::empty(),
Statement::Discard { .. } => Span::empty(),
Statement::SetRole { .. } => Span::empty(),
Statement::SetVariable { .. } => Span::empty(),
Statement::SetTimeZone { .. } => Span::empty(),
Statement::SetNames { .. } => Span::empty(),
Statement::SetNamesDefault {} => Span::empty(),
Statement::Set(_) => Span::empty(),
Statement::ShowFunctions { .. } => Span::empty(),
Statement::ShowVariable { .. } => Span::empty(),
Statement::ShowStatus { .. } => Span::empty(),
Expand All @@ -459,7 +450,6 @@ impl Spanned for Statement {
Statement::ShowCollation { .. } => Span::empty(),
Statement::Use(u) => u.span(),
Statement::StartTransaction { .. } => Span::empty(),
Statement::SetTransaction { .. } => Span::empty(),
Statement::Comment { .. } => Span::empty(),
Statement::Commit { .. } => Span::empty(),
Statement::Rollback { .. } => Span::empty(),
Expand Down Expand Up @@ -508,7 +498,6 @@ impl Spanned for Statement {
Statement::RenameTable { .. } => Span::empty(),
Statement::RaisError { .. } => Span::empty(),
Statement::List(..) | Statement::Remove(..) => Span::empty(),
Statement::SetSessionParam { .. } => Span::empty(),
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/dialect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,16 @@ pub trait Dialect: Debug + Any {
false
}

/// Returns true if the dialect supports multiple `SET` statements
/// in a single statement.
///
/// ```sql
/// SET variable = expression [, variable = expression];
/// ```
fn supports_comma_separated_set_assignments(&self) -> bool {
false
}

/// Returns true if the dialect supports an `EXCEPT` clause following a
/// wildcard in a select list.
///
Expand Down
1 change: 1 addition & 0 deletions src/dialect/mssql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ impl Dialect for MsSqlDialect {
fn supports_start_transaction_modifier(&self) -> bool {
true
}

fn supports_end_transaction_modifier(&self) -> bool {
true
}
Expand Down
4 changes: 4 additions & 0 deletions src/dialect/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ impl Dialect for MySqlDialect {
fn supports_set_names(&self) -> bool {
true
}

fn supports_comma_separated_set_assignments(&self) -> bool {
true
}
}

/// `LOCK TABLES`
Expand Down
2 changes: 2 additions & 0 deletions src/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ define_keywords!(
CHANNEL,
CHAR,
CHARACTER,
CHARACTERISTICS,
CHARACTERS,
CHARACTER_LENGTH,
CHARSET,
Expand Down Expand Up @@ -557,6 +558,7 @@ define_keywords!(
MULTISET,
MUTATION,
NAME,
NAMES,
NANOSECOND,
NANOSECONDS,
NATIONAL,
Expand Down
Loading