Use _effective_decimal_return_scale in Numeric.result_processor#13137
Use _effective_decimal_return_scale in Numeric.result_processor#13137bysiber wants to merge 1 commit intosqlalchemy:mainfrom
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.
|
Hi, The PR template asks to open an issue before creating a PR. It's not that difficult an ask. What's the issue we are trying to solve here? |
|
Apologies for skipping the issue step I'll open one now. The problem is in |
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.