Conversation
Changes the way `Config` is contructed by introducing helper struct `ConfigBuilder`, which follows the builder pattern. This enables more ergonomic function call chaining, while still preserving the option to call them one by one as previously.
joelparkerhenderson
added a commit
to mssql-rust/mssql-rust
that referenced
this pull request
Aug 29, 2026
Mirrors the idea of tiberius-rs/tiberius#366, but not its diff: as tasks.md flagged, the upstream PR outright deleted `Config::new()` and every one of its setters, replacing them with a builder-only API - a breaking change for essentially every existing caller (including this fork's own docs, examples, and every test in the suite). Reimplemented from scratch as a pure addition instead: `Config::new()` and all of its setters are completely untouched. `Config::builder()` returns a new `ConfigBuilder` wrapping a `Config`, with one chainable (`&mut Self`-returning) method per existing setter - covering every setter this fork now has, including the ones added this session that didn't exist when #366 was opened (`client_name`, `host_name_in_certificate`, `send_string_parameters_as_unicode`, `multi_subnet_failover`, `packet_size`). Each builder method just calls straight through to the corresponding `Config` method, so there is exactly one implementation of each setting's logic. `packet_size` is the one fallible setter (range-validated, added this session in #400) - its builder method returns `crate::Result<&mut Self>` instead of `&mut Self`, so chaining continues normally with `?` on success. `build(&self)` clones the wrapped `Config` rather than consuming the builder, so a builder can be reused as a shared base for producing several slightly different `Config`s (matching the shape of the original PR's `build`, which was worth keeping even though the rest of that PR wasn't). Added unit tests confirming: `Config::new()` and its direct setters still compile and work unmodified, the builder produces a `Config` equivalent to the direct-setter path for the same values, the builder remains usable after `build()`, and `packet_size`'s validation/chaining behavior. Verified: - cargo check: default, --features=rustls, --features=vendored-openssl, --no-default-features - cargo clippy --all-targets -- -D warnings, for default and rustls - cargo fmt --check - cargo test --lib (181 passed) - cargo test --doc against a live server (28 passed, including the new ConfigBuilder doctest) - Live integration tests over rustls: 305 passed (102 bulk + 203 query), unaffected since this is purely additive 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
Adapted from upstream #366 (author @LonerDan), non-breaking (existing Config API retained).
joelparkerhenderson
added a commit
to mssql-rust/mssql-rust
that referenced
this pull request
Aug 30, 2026
Mirrors the idea of tiberius-rs/tiberius#366, but not its diff: as tasks.md flagged, the upstream PR outright deleted `Config::new()` and every one of its setters, replacing them with a builder-only API - a breaking change for essentially every existing caller (including this fork's own docs, examples, and every test in the suite). Reimplemented from scratch as a pure addition instead: `Config::new()` and all of its setters are completely untouched. `Config::builder()` returns a new `ConfigBuilder` wrapping a `Config`, with one chainable (`&mut Self`-returning) method per existing setter - covering every setter this fork now has, including the ones added this session that didn't exist when #366 was opened (`client_name`, `host_name_in_certificate`, `send_string_parameters_as_unicode`, `multi_subnet_failover`, `packet_size`). Each builder method just calls straight through to the corresponding `Config` method, so there is exactly one implementation of each setting's logic. `packet_size` is the one fallible setter (range-validated, added this session in #400) - its builder method returns `crate::Result<&mut Self>` instead of `&mut Self`, so chaining continues normally with `?` on success. `build(&self)` clones the wrapped `Config` rather than consuming the builder, so a builder can be reused as a shared base for producing several slightly different `Config`s (matching the shape of the original PR's `build`, which was worth keeping even though the rest of that PR wasn't). Added unit tests confirming: `Config::new()` and its direct setters still compile and work unmodified, the builder produces a `Config` equivalent to the direct-setter path for the same values, the builder remains usable after `build()`, and `packet_size`'s validation/chaining behavior. Verified: - cargo check: default, --features=rustls, --features=vendored-openssl, --no-default-features - cargo clippy --all-targets -- -D warnings, for default and rustls - cargo fmt --check - cargo test --lib (181 passed) - cargo test --doc against a live server (28 passed, including the new ConfigBuilder doctest) - Live integration tests over rustls: 305 passed (102 bulk + 203 query), unaffected since this is purely additive Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0156Di1tRRLsJK8ctU1AmAJr
This was referenced Sep 1, 2026
MattJackson
added a commit
that referenced
this pull request
Sep 3, 2026
MattJackson
added a commit
that referenced
this pull request
Sep 4, 2026
MattJackson
added a commit
that referenced
this pull request
Sep 6, 2026
MattJackson
added a commit
that referenced
this pull request
Sep 16, 2026
MattJackson
added a commit
that referenced
this pull request
Sep 24, 2026
Contributor
|
Included in #442 — shipped in tiberius v0.13.0. Thanks for this! Closing. |
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.
Changes the way
Configis constructed by introducing helper structConfigBuilder, which follows the builder pattern. This enables more ergonomic function call chaining, while still preserving the option to call them one by one as previously.Based on this and this, the variant consuming and producing mutable references was chosen, since it allows both ergonomic function call chaining and manually calling individual functions, which is required in case of values set conditionally.
As a side effect, this also allows constructing multiple
Configs from the same builder.