Add method to query column metadata - #398
Open
etylermoss wants to merge 8 commits into
Open
Conversation
Author
|
It should be considered to combine with #359 so that you can provide the (possibly subset) list of column metadata to |
Adds `bulk_insert_columns(self, table, columns)` and turns `bulk_insert(self, table)` into a compatibility shim that calls `self.bulk_insert_columns(table, &["*"])`, maintaining the existing behaviour.
Author
|
Merged with #359. |
Remove unnecessary lifetimes.
Fix merge - surround only column name with [].
joelparkerhenderson
added a commit
to mssql-rust/mssql-rust
that referenced
this pull request
Aug 29, 2026
Mirrors the ColumnFlag-renumbering portion of tiberius-rs/tiberius#398 (its column_metadata()/bulk_insert_columns API portion was already implemented this session as part of #359). ColumnFlag's bit values did not match MS-TDS 2.2.7.4 COLMETADATA's `Flags` field (verified against the current Microsoft Learn spec text): Updateable, UpdateableUnknown, Identity, Computed, FixedLenClrType, SparseColumnSet, and Encrypted were each off by 1-2 bits (Hidden, Key, and NullableUnknown were already correct). Concretely, a server's real `fIdentity` bit (0x10) decoded as `UpdateableUnknown`, and `fComputed` (0x20) wasn't representable at all under the old numbering. `usUpdateable` is a 2-bit *value* (0 = read-only, 1 = read/write, 2 = updateable-unknown), not two independent flags. `bulk_insert_columns`'s existing filter (`.filter(|c| c.flags.contains(ColumnFlag::Updateable))`) happened to keep working operationally only because its old, wrong `Updateable` bit position (1<<3) coincided with the real spec's `UpdateableUnknown` bit (0x08) - and SQL Server, in practice, reports ordinary SELECT columns as updateable-unknown rather than definitively read/write, only marking identity/computed columns definitively read-only (0). Now that the bits are spec-correct, the filter is updated to `intersects(Updateable | UpdateableUnknown)`, i.e. "not explicitly read-only" - checking `Updateable` alone would incorrectly exclude ordinary columns. Added: - 12 unit tests in token_col_metadata.rs decoding a raw wire value per flag against its expected bit position (verified 7 of them fail against the pre-fix bit numbering, restored to pass with the fix). - A live regression test (bulk_insert_excludes_identity_and_computed_columns) confirming a wildcard bulk_insert against a table with an IDENTITY column and a COMPUTED column excludes both while still inserting into the ordinary column. Verified: - cargo check: default, --features=rustls, --features=vendored-openssl, --no-default-features - cargo clippy --all-targets -- -D warnings - cargo fmt --check - cargo test --lib (162 passed) - Live integration tests against a running Azure SQL Edge container over rustls: 294 passed (92 bulk + 202 query) 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 29, 2026
Completes the remaining API portion of tiberius-rs/tiberius#398 (the ColumnFlag bit-position fix landed separately in e7eb6e4). Adds `Client::column_metadata(table, columns)`, factored out of `bulk_insert_columns`'s existing metadata-fetching logic so both share one implementation: it runs a `SELECT TOP 0` and returns each column's name, type, and flags (nullability, identity, computed, etc.) without touching any row data. `bulk_insert_columns` now calls it and applies its own Updateable/UpdateableUnknown filter on top. `MetaDataColumn` is now re-exported at the crate root so the return type is nameable by callers; added doc comments to it and its fields to satisfy `#![warn(missing_docs)]` now that it's public API surface. Verified: - cargo check: default, --features=rustls, --features=vendored-openssl, --no-default-features - cargo clippy --all-targets -- -D warnings, for default, rustls, and vendored-openssl feature sets - cargo fmt --check - cargo test --lib (162 passed) - cargo test --doc --no-default-features --features=rustls,tds73,chrono, rust_decimal,bigdecimal,time against a live server (26 passed, including the new column_metadata doctest) - Live integration tests over rustls: 294 passed (92 bulk + 202 query) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0156Di1tRRLsJK8ctU1AmAJr
MattJackson
referenced
this pull request
in MattJackson/tiberius-ng
Aug 29, 2026
…397, #217, #403) Adapted from upstream #398 (author @etylermoss), reconciled with the already-integrated bulk_insert_columns (#359): - Client::column_metadata(table, columns) returns owned Vec<MetaDataColumn> (names, types, size/precision/scale, nullability, identity); bulk insert now shares this path. - MetaDataColumn::col_name()/base() accessors; BaseMetaDataColumn:: is_identity()/is_nullable()/ty()/flags() (resolves #403).
joelparkerhenderson
added a commit
to mssql-rust/mssql-rust
that referenced
this pull request
Aug 30, 2026
Mirrors the ColumnFlag-renumbering portion of tiberius-rs/tiberius#398 (its column_metadata()/bulk_insert_columns API portion was already implemented this session as part of #359). ColumnFlag's bit values did not match MS-TDS 2.2.7.4 COLMETADATA's `Flags` field (verified against the current Microsoft Learn spec text): Updateable, UpdateableUnknown, Identity, Computed, FixedLenClrType, SparseColumnSet, and Encrypted were each off by 1-2 bits (Hidden, Key, and NullableUnknown were already correct). Concretely, a server's real `fIdentity` bit (0x10) decoded as `UpdateableUnknown`, and `fComputed` (0x20) wasn't representable at all under the old numbering. `usUpdateable` is a 2-bit *value* (0 = read-only, 1 = read/write, 2 = updateable-unknown), not two independent flags. `bulk_insert_columns`'s existing filter (`.filter(|c| c.flags.contains(ColumnFlag::Updateable))`) happened to keep working operationally only because its old, wrong `Updateable` bit position (1<<3) coincided with the real spec's `UpdateableUnknown` bit (0x08) - and SQL Server, in practice, reports ordinary SELECT columns as updateable-unknown rather than definitively read/write, only marking identity/computed columns definitively read-only (0). Now that the bits are spec-correct, the filter is updated to `intersects(Updateable | UpdateableUnknown)`, i.e. "not explicitly read-only" - checking `Updateable` alone would incorrectly exclude ordinary columns. Added: - 12 unit tests in token_col_metadata.rs decoding a raw wire value per flag against its expected bit position (verified 7 of them fail against the pre-fix bit numbering, restored to pass with the fix). - A live regression test (bulk_insert_excludes_identity_and_computed_columns) confirming a wildcard bulk_insert against a table with an IDENTITY column and a COMPUTED column excludes both while still inserting into the ordinary column. Verified: - cargo check: default, --features=rustls, --features=vendored-openssl, --no-default-features - cargo clippy --all-targets -- -D warnings - cargo fmt --check - cargo test --lib (162 passed) - Live integration tests against a running Azure SQL Edge container over rustls: 294 passed (92 bulk + 202 query) 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
Completes the remaining API portion of tiberius-rs/tiberius#398 (the ColumnFlag bit-position fix landed separately in b258866). Adds `Client::column_metadata(table, columns)`, factored out of `bulk_insert_columns`'s existing metadata-fetching logic so both share one implementation: it runs a `SELECT TOP 0` and returns each column's name, type, and flags (nullability, identity, computed, etc.) without touching any row data. `bulk_insert_columns` now calls it and applies its own Updateable/UpdateableUnknown filter on top. `MetaDataColumn` is now re-exported at the crate root so the return type is nameable by callers; added doc comments to it and its fields to satisfy `#![warn(missing_docs)]` now that it's public API surface. Verified: - cargo check: default, --features=rustls, --features=vendored-openssl, --no-default-features - cargo clippy --all-targets -- -D warnings, for default, rustls, and vendored-openssl feature sets - cargo fmt --check - cargo test --lib (162 passed) - cargo test --doc --no-default-features --features=rustls,tds73,chrono, rust_decimal,bigdecimal,time against a live server (26 passed, including the new column_metadata doctest) - Live integration tests over rustls: 294 passed (92 bulk + 202 query) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0156Di1tRRLsJK8ctU1AmAJr
This was referenced Sep 1, 2026
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.
Fixes #397