Opened 13 years ago

Closed 13 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

Description

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

CREATE TABLE  "TEST_TABLE" 
   (	"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 by rodolfo.3+django@…, 13 years ago

Component: UncategorizedCore (Management commands)
Type: UncategorizedBug

comment:2 by Aymeric Augustin, 13 years ago

Resolution: wontfix
Status: newclosed

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