{{ message }}
Use _effective_decimal_return_scale in Numeric.result_processor#13137
Open
bysiber wants to merge 1 commit into
Open
Use _effective_decimal_return_scale in Numeric.result_processor#13137bysiber wants to merge 1 commit into
bysiber wants to merge 1 commit into
Conversation
Numeric.result_processor was computing the return scale inline, skipping the decimal_return_scale parameter entirely. Float already uses _effective_decimal_return_scale which checks decimal_return_scale first. This brings Numeric in line with Float and honors the decimal_return_scale parameter as documented.
Member
Contributor
Author
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.

Description
Numeric.result_processorcomputes the decimal return scale inline, bypassing thedecimal_return_scaleparameter, whileFloat.result_processorcorrectly uses_effective_decimal_return_scale.Current behavior
The
_effective_decimal_return_scaleproperty (fromNumericCommon) checksself.decimal_return_scalefirst, then falls back toself.scale, then_default_decimal_return_scale. The inline logic inNumericskips thedecimal_return_scalecheck entirely.This means
Numeric(precision=10, scale=2, decimal_return_scale=5)would use scale 2 instead of 5 when the DBAPI doesn't support native decimals.Fix
Use
self._effective_decimal_return_scale, same asFloat.result_processoralready does.