Opened 4 years ago

Closed 4 years ago

#17227 closed Bug (wontfix)

max_digits and decimal_places using "inspectdb"

Reported by: anonymous Owned by: nobody
Component: Core (Management commands) Version:
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I'm using Oracle and have a table like this:

   (	"NUMBER_2_0" NUMBER(2,0)

When I use "inspectdb", the generated model looks like:

class TestTable(models.Model):
    number_2_0 = models.IntegerField(null=True, blank=True)
    class Meta:
        db_table = u'test_table'

But the field should be a "models.DecimalField" with "max_digits=2" and "decimal_places=0".

Change History (2)

comment:1 Changed 4 years ago by rodolfo.3+django@…

  • Component changed from Uncategorized to Core (Management commands)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Type changed from Uncategorized to Bug

comment:2 Changed 4 years ago by aaugustin

  • Resolution set to wontfix
  • Status changed from new to closed

By design, Django considers a NUMBER field with a scale of 0 as an IntegerField.

This behavior was introduced in r11475 to fix #11049, and I think it's correct. It's better to introspect IntegerFields created by Django as IntegerFields, and occasionally misinterpret a DecimalField as an IntegerField, than to consider all IntegerFields as DecimalFields.

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