fix-spaces: allow queries on column names with spaces - #387
Open
polina-alekseeva-rogii wants to merge 7 commits into
Open
fix-spaces: allow queries on column names with spaces#387polina-alekseeva-rogii wants to merge 7 commits into
polina-alekseeva-rogii wants to merge 7 commits into
Conversation
joelparkerhenderson
added a commit
to mssql-rust/mssql-rust
that referenced
this pull request
Aug 29, 2026
Combines tiberius-rs/tiberius#387 (correct escaping) and #388 (test coverage) -- neither alone was complete: #387 escapes an embedded `]` but ships no test, #388 has a test but doesn't escape `]`. Also resolves the same underlying bug reported separately in #296/#398. A column named after a reserved word or containing a space (e.g. `[End]`) broke bulk_insert, since the INSERT BULK/SELECT TOP 0 statement text that MetaDataColumn::Display generates from the server's own reported column metadata didn't quote the name at all. Now brackets it, doubling any literal `]` per SQL Server's own escaping rule for quoted identifiers (`]` -> `]]`), so a column that itself contains `]` can't break out of the quoted identifier into the surrounding statement text. Added regression tests in both tests/bulk.rs (a bulk_insert into an `[End] INT` column) and tests/query.rs (manually-bracket-quoted execute/query against the same), ported from #388. Confirmed the bulk.rs test fails without this fix ("Incorrect syntax near the keyword 'End'") and passes with it. Note: Client::bulk_insert_columns's caller-supplied column list (added this session, #359) is a related but separate gap -- it isn't bracket-quoted either, and fixing that needs to special-case the "*" wildcard so it isn't itself quoted. Left out of scope here to avoid touching that just-shipped, already-tested feature; worth a follow-up. Verified live against a real SQL Server (Azure SQL Edge via rustls): 292 tests total (202 in tests/query.rs, 90 in tests/bulk.rs). Also verified: cargo check across all 6 CI feature combinations, cargo clippy --all-targets, cargo fmt --check, and cargo test --lib (153 passing). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0156Di1tRRLsJK8ctU1AmAJr
joelparkerhenderson
added a commit
to mssql-rust/mssql-rust
that referenced
this pull request
Aug 30, 2026
Combines tiberius-rs/tiberius#387 (correct escaping) and #388 (test coverage) -- neither alone was complete: #387 escapes an embedded `]` but ships no test, #388 has a test but doesn't escape `]`. Also resolves the same underlying bug reported separately in #296/#398. A column named after a reserved word or containing a space (e.g. `[End]`) broke bulk_insert, since the INSERT BULK/SELECT TOP 0 statement text that MetaDataColumn::Display generates from the server's own reported column metadata didn't quote the name at all. Now brackets it, doubling any literal `]` per SQL Server's own escaping rule for quoted identifiers (`]` -> `]]`), so a column that itself contains `]` can't break out of the quoted identifier into the surrounding statement text. Added regression tests in both tests/bulk.rs (a bulk_insert into an `[End] INT` column) and tests/query.rs (manually-bracket-quoted execute/query against the same), ported from #388. Confirmed the bulk.rs test fails without this fix ("Incorrect syntax near the keyword 'End'") and passes with it. Note: Client::bulk_insert_columns's caller-supplied column list (added this session, #359) is a related but separate gap -- it isn't bracket-quoted either, and fixing that needs to special-case the "*" wildcard so it isn't itself quoted. Left out of scope here to avoid touching that just-shipped, already-tested feature; worth a follow-up. Verified live against a real SQL Server (Azure SQL Edge via rustls): 292 tests total (202 in tests/query.rs, 90 in tests/bulk.rs). Also verified: cargo check across all 6 CI feature combinations, cargo clippy --all-targets, cargo fmt --check, and cargo test --lib (153 passing). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0156Di1tRRLsJK8ctU1AmAJr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changed the code to support spaces in column names in bulk insert.