Skip to content

add intosql impls for decimal - #376

Closed
esheppa wants to merge 3 commits into
tiberius-rs:mainfrom
esheppa:decimal-intosql
Closed

esheppa wants to merge 3 commits into
tiberius-rs:mainfrom
esheppa:decimal-intosql

Conversation

@esheppa

@esheppa esheppa commented Mar 25, 2025

Copy link
Copy Markdown
Contributor

These features seem to have been omitted for Decimal so I've added IntoSql imps - because it is a copy type the implementation is identical to that of ToSql

MattJackson referenced this pull request in MattJackson/tiberius-ng Aug 29, 2026
From upstream #376 (author Eric Sheppard) — the numeric.rs IntoSql impl
only; the PR's stale edits to CI/TLS files (already covered by #419) are
omitted. Lets a rust_decimal Decimal be bound directly in queries.
joelparkerhenderson added a commit to mssql-rust/mssql-rust that referenced this pull request Aug 29, 2026
Cherry-picks just the decimal hunk of tiberius-rs/tiberius#376. Its other
hunks (CI actions/cache v2->v4, several event! log levels changed from
INFO to DEBUG) were dropped: the CI bump is already superseded here (this
fork's CI is SHA-pinned to actions/cache v5.0.5, see tasks.md's "Already
superseded" section) and the log-level changes are unrelated to the
decimal fix, so they're left for a separate change if wanted.

`Decimal` already had `FromSql` and `ToSql` (borrowed) impls but was
missing `IntoSql` (owned/consuming) - the same gap `BigDecimal` didn't
have, since it already has all three. This meant `Decimal` values
couldn't be used with APIs that consume rather than borrow, notably
`TokenRow::push(value.into_sql())` for bulk_insert.

Added a regression test proving this: `test_bulk_type!(decimal(...))` in
tests/bulk.rs, which expands to bulk-insert tests calling
`i.into_sql()` - confirmed this fails to compile without the fix
("no method named `into_sql` found for struct `Decimal`") and compiles
and passes live with it.

Verified:
- cargo check: default, --features=rustls, --features=vendored-openssl,
  --no-default-features, --features=rust_decimal,tds73
- cargo clippy --all-targets -- -D warnings, for default and
  rust_decimal,tds73,rustls
- cargo fmt --check
- cargo test --lib --features=rust_decimal,tds73 (176 passed)
- Live integration tests over rustls: 305 passed (102 bulk + 203 query,
  including the new decimal bulk-insert tests)

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
Cherry-picks just the decimal hunk of tiberius-rs/tiberius#376. Its other
hunks (CI actions/cache v2->v4, several event! log levels changed from
INFO to DEBUG) were dropped: the CI bump is already superseded here (this
fork's CI is SHA-pinned to actions/cache v5.0.5, see tasks.md's "Already
superseded" section) and the log-level changes are unrelated to the
decimal fix, so they're left for a separate change if wanted.

`Decimal` already had `FromSql` and `ToSql` (borrowed) impls but was
missing `IntoSql` (owned/consuming) - the same gap `BigDecimal` didn't
have, since it already has all three. This meant `Decimal` values
couldn't be used with APIs that consume rather than borrow, notably
`TokenRow::push(value.into_sql())` for bulk_insert.

Added a regression test proving this: `test_bulk_type!(decimal(...))` in
tests/bulk.rs, which expands to bulk-insert tests calling
`i.into_sql()` - confirmed this fails to compile without the fix
("no method named `into_sql` found for struct `Decimal`") and compiles
and passes live with it.

Verified:
- cargo check: default, --features=rustls, --features=vendored-openssl,
  --no-default-features, --features=rust_decimal,tds73
- cargo clippy --all-targets -- -D warnings, for default and
  rust_decimal,tds73,rustls
- cargo fmt --check
- cargo test --lib --features=rust_decimal,tds73 (176 passed)
- Live integration tests over rustls: 305 passed (102 bulk + 203 query,
  including the new decimal bulk-insert tests)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0156Di1tRRLsJK8ctU1AmAJr
MattJackson pushed a commit that referenced this pull request Sep 3, 2026
From upstream #376 (author Eric Sheppard) — the numeric.rs IntoSql impl
only; the PR's stale edits to CI/TLS files (already covered by #419) are
omitted. Lets a rust_decimal Decimal be bound directly in queries.

(cherry picked from commit 54bf399)
MattJackson pushed a commit that referenced this pull request Sep 4, 2026
From upstream #376 (author Eric Sheppard) — the numeric.rs IntoSql impl
only; the PR's stale edits to CI/TLS files (already covered by #419) are
omitted. Lets a rust_decimal Decimal be bound directly in queries.

(cherry picked from commit 54bf399)
MattJackson pushed a commit that referenced this pull request Sep 6, 2026
From upstream #376 (author Eric Sheppard) — the numeric.rs IntoSql impl
only; the PR's stale edits to CI/TLS files (already covered by #419) are
omitted. Lets a rust_decimal Decimal be bound directly in queries.

(cherry picked from commit 54bf399)
MattJackson pushed a commit that referenced this pull request Sep 15, 2026
From upstream #376 (author Eric Sheppard) — the numeric.rs IntoSql impl
only; the PR's stale edits to CI/TLS files (already covered by #419) are
omitted. Lets a rust_decimal Decimal be bound directly in queries.

(cherry picked from commit 54bf399)
MattJackson pushed a commit that referenced this pull request Sep 16, 2026
From upstream #376 (author Eric Sheppard) — the numeric.rs IntoSql impl
only; the PR's stale edits to CI/TLS files (already covered by #419) are
omitted. Lets a rust_decimal Decimal be bound directly in queries.

(cherry picked from commit 54bf399)
@MattJackson

Copy link
Copy Markdown
Contributor

Included in #441 — shipped in tiberius v0.13.0. Thanks for this! Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants