43 | | In the scenario where decimal_places is 0 and the input is 9999999999999999 (16 digits) the result of the quantization is 10000000000000000 (17 digits), i assume this is because of SQLite's quirk of only preserving the first 15 significant bits. So the root cause is the same for both errors. |
| 43 | The above situation can occur whenever the integral part of the number has more digits than `max_digits-decimal_places`** not just when the integer part has more than 15 digits**. The postgres backend automatically handles this situation by throwing the following error: |
| 44 | {{{ |
| 45 | django.db.utils.DataError: numeric field overflow |
| 46 | DETAIL: A field with precision <max_digits>, scale <decimal_places> must round to an absolute value less than 10^<max_digits-decimal_places>. |
| 47 | }}} |
| 48 | |
| 49 | SQLite however has no native Decimal Type so it has no handling for this. |
| 50 | |
| 51 | In the scenario where decimal_places is 0 and the input is 9999999999999999 (16 digits) the result of the quantization is 10000000000000000 (17 digits), i assume this is because of SQLite's quirk of only preserving the first 15 significant bits. This is a separate issue albeit the error is the same. |