Skip to content

MsSql: Keep the comma separator when displaying DECLARE lists - #2671

Merged
LucaCappelletti94 merged 1 commit into
mainfrom
mssql-declare-comma-separator
Oct 21, 2026
Merged

LucaCappelletti94 merged 1 commit into
mainfrom
mssql-declare-comma-separator

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

In MsSql one DECLARE keyword takes a comma-separated list of declarations, DECLARE @a INT, @b INT (https://learn.microsoft.com/en-us/sql/t-sql/language-elements/declare-local-variable-transact-sql). The parser collected the list into one Statement::Declare, but the display joined it with ; , so the statement was printed back as DECLARE @a INT; @b INT, which T-SQL reads as a different statement.

Statement::Declare gains a separator: DeclareSeparator field. The MsSql parser records Comma, and the Snowflake, BigQuery and cursor forms record Semicolon, matching Snowflake Scripting's DECLARE section where each declaration ends with ; (https://docs.snowflake.com/en/sql-reference/snowflake-scripting/declare).

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.26%. Comparing base (1aabd12) to head (b634c00).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2671      +/-   ##
==========================================
+ Coverage   81.25%   81.26%   +0.01%     
==========================================
  Files          42       42              
  Lines       33910    33920      +10     
  Branches    33910    33920      +10     
==========================================
+ Hits        27553    27566      +13     
+ Misses       2792     2790       -2     
+ Partials     3565     3564       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread tests/sqlparser_mssql.rs
}

#[test]
fn parse_mssql_declare_comma_list_display() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any tests for ; as a separator 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not add one because it is already present in several other tests as part of the existing syntax. It does not have a dedicated test.

@LucaCappelletti94
LucaCappelletti94 added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 9cacf35 Oct 21, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api change bug Something isn't working SQL Server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants