Skip to content

Encode negative-scale BigDecimal values correctly - #1776

Open
sharanggupta wants to merge 1 commit into
eclipse-vertx:masterfrom
sharanggupta:mssql-negative-scale-decimal
Open

sharanggupta wants to merge 1 commit into
eclipse-vertx:masterfrom
sharanggupta:mssql-negative-scale-decimal

Conversation

@sharanggupta

Copy link
Copy Markdown

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.

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)
@vietj vietj added this to the 5.3.0 milestone Oct 29, 2026

This branch has not been deployed

No deployments
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