Skip to content

[MSSQL] Encode negative-scale BigDecimal values correctly - #1776

Merged
tsegismont merged 2 commits into
eclipse-vertx:masterfrom
sharanggupta:mssql-negative-scale-decimal
Nov 13, 2026
Merged

tsegismont merged 2 commits into
eclipse-vertx:masterfrom
sharanggupta:mssql-negative-scale-decimal

Conversation

@sharanggupta

Copy link
Copy Markdown
Contributor

A BigDecimal parameter with a negative scale, which stripTrailingZeros() produces routinely, is sent with its scale clamped to zero but its unscaled value unchanged, so new BigDecimal("1500").stripTrailingZeros() (15E+2) is stored as 15. The value is now rescaled to zero before encoding. Verified against the SQL Server engine (Azure SQL Edge) with the module's init.sql; the data type tests pass apart from the JSON ones, which need SQL Server 2025.

@vietj vietj added this to the 5.3.0 milestone Oct 29, 2026
@tsegismont tsegismont changed the title Encode negative-scale BigDecimal values correctly MSSQL Encode negative-scale BigDecimal values correctly Nov 12, 2026

@tsegismont tsegismont left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @sharanggupta !

@tsegismont tsegismont left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Forgot this one

@tsegismont tsegismont changed the title MSSQL Encode negative-scale BigDecimal values correctly [MSSQL] Encode negative-scale BigDecimal values correctly Nov 12, 2026
@tsegismont tsegismont added the bug label Nov 12, 2026
The scale byte was clamped to zero but the unscaled value was not
multiplied back, so 1.5E+3 (1500 after stripTrailingZeros) was sent
as 15.

Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
Assisted-by: Anthropic Claude (claude-opus-5-5)
Compute the scale once for the parameter definition and the encoded
value, and cover a negative value with a negative scale.

Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
Assisted-by: Anthropic Claude (claude-fable-5-2)
@tsegismont
tsegismont force-pushed the mssql-negative-scale-decimal branch from 3397f43 to d68d08d Compare November 13, 2026 10:20

@tsegismont tsegismont left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you

@tsegismont
tsegismont merged commit aa33932 into eclipse-vertx:master Nov 13, 2026
20 checks passed
tsegismont added a commit that referenced this pull request Nov 13, 2026
)

* Encode negative-scale BigDecimal values correctly

The scale byte was clamped to zero but the unscaled value was not
multiplied back, so 1.5E+3 (1500 after stripTrailingZeros) was sent
as 15.


Assisted-by: Anthropic Claude (claude-opus-5-5)

* Extract the numeric parameter scale

Compute the scale once for the parameter definition and the encoded
value, and cover a negative value with a negative scale.


Assisted-by: Anthropic Claude (claude-fable-5-2)

---------


(cherry picked from commit aa33932)

Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
Co-authored-by: Sharang Gupta <sharang@sharanggupta.dev>
tsegismont added a commit that referenced this pull request Nov 13, 2026
)

* Encode negative-scale BigDecimal values correctly

The scale byte was clamped to zero but the unscaled value was not
multiplied back, so 1.5E+3 (1500 after stripTrailingZeros) was sent
as 15.


Assisted-by: Anthropic Claude (claude-opus-5-5)

* Extract the numeric parameter scale

Compute the scale once for the parameter definition and the encoded
value, and cover a negative value with a negative scale.


Assisted-by: Anthropic Claude (claude-fable-5-2)

---------


(cherry picked from commit aa33932)

Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
Co-authored-by: Sharang Gupta <sharang@sharanggupta.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants