Opened 11 years ago

Closed 11 months ago

Last modified 8 weeks ago

#24920 closed New feature (fixed)

Database type NUMERIC with no parameters is not supported

Reported by: Shai Berger Owned by: Mariusz Felisiak
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: oracle
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django's DecimalField requires both max_digits and decimal_places. Database backends allow them to be dropped, to specify an "unlimited precision" field.

This leads to bugs in inspectdb: On Oracle, a column defined as NUMERIC is inspected as having 0 digits and negative precision; on Postgresql, it is inspected as having 65535 (a C short -1?) digits and decimal places, when the ​documentation says you can only explicitly define up to 1000 decimal places (and even the implicitly defined precision is only 16383).

Discussion in the context of Oracle (from 2012):
​https://groups.google.com/d/topic/django-developers/qSAfzPyqKqw/discussion

(This could be solved more easily by adding a new field type than by modifying the behavior of the existing DecimalField; however, I'm having a hard time suggesting a name for such a field type, which may be an indication that it is a bad interface. Besides that decision, this probably applies as an easy picking).

Change History (11)

comment:1 by Tim Graham, 11 years ago

Easy pickings: unset
Needs documentation: unset
Needs tests: unset
Triage Stage: Unreviewed → Accepted

Maybe you could raise the idea on the DevelopersMailingList. I think I'd prefer if we didn't need to add a new field, but if so, I'll propose the name ImpreciseDecimalField. Seems like a name like that might scare people away from using it though.

comment:2 by Maciej Gol, 10 years ago

Any update on this or a suggested way of resolving: either new field or a fix to DecimalField?

comment:3 by Tim Graham, 10 years ago

If you want to propose a solution, please write to the DevelopersMailingList to get feedback about how to proceed.

comment:4 by Tim Graham, 12 months ago

On the ​django-developers thread, Aymeric proposed trying to adapt DecimalField rather than introduce a new field, and Claude gave that idea a +1.

#36673 is a duplicate that requests making DecimalField's max_digits and decimal_places optional.

Version 0, edited 12 months ago by Tim Graham (next)

comment:5 by Mariusz Felisiak, 11 months ago

Owner: changed from nobody to Mariusz Felisiak
Status: new → assigned

comment:6 by Mariusz Felisiak, 11 months ago

Has patch: set

comment:7 by Lily, 11 months ago

Triage Stage: Accepted → Ready for checkin

comment:8 by GitHub <noreply@…>, 11 months ago

Resolution: → fixed
Status: assigned → closed

In 1ce6e78:

Fixed #24920 -- Added support for DecimalField with no precision.

Thanks Lily for the review.

comment:9 by GitHub <noreply@…>, 10 months ago

In 1c34b871:

Refs #24920 -- Made DecimalField system checks database dependent.

Thanks Tim Graham for the suggestion.

comment:10 by Sarah Boyce <42296566+sarahboyce@…>, 8 weeks ago

In a3e6e7d:

Fixed #37275, Refs #24920 -- Fixed SQLite DecimalField conversion without precision.

Thank you Matt Cooper for the report and Mariusz Felisiak for the review.

comment:11 by Sarah Boyce <42296566+sarahboyce@…>, 8 weeks ago

In ad6bc546:

[6.1.x] Fixed #37275, Refs #24920 -- Fixed SQLite DecimalField conversion without precision.

Thank you Matt Cooper for the report and Mariusz Felisiak for the review.

Backport of a3e6e7d3aa6e2aa793ba1d122a76cb007727197c from main.

Note: See TracTickets for help on using tickets.
Back to Top