Fixed #5014 -- Guessed max_digits and decimal_places for SQLite
Decimal is treated as float on SQLite, hence inspectdb can only guess max_digits and decimal_places arguments.
This commit is contained in:
parent
51028f50b6
commit
dcf563071f
|
@ -213,6 +213,13 @@ class Command(NoArgsCommand):
|
|||
field_params['max_length'] = int(row[3])
|
||||
|
||||
if field_type == 'DecimalField':
|
||||
if row[4] is None or row[5] is None:
|
||||
field_notes.append(
|
||||
'max_digits and decimal_places have been guessed, as this '
|
||||
'database handles decimal fields as float')
|
||||
field_params['max_digits'] = row[4] if row[4] is not None else 10
|
||||
field_params['decimal_places'] = row[5] if row[5] is not None else 5
|
||||
else:
|
||||
field_params['max_digits'] = row[4]
|
||||
field_params['decimal_places'] = row[5]
|
||||
|
||||
|
|
|
@ -55,8 +55,9 @@ class InspectDBTestCase(TestCase):
|
|||
assertFieldType('date_field', "models.DateField()")
|
||||
assertFieldType('date_time_field', "models.DateTimeField()")
|
||||
if connection.vendor == 'sqlite':
|
||||
# Ticket #5014
|
||||
assertFieldType('decimal_field', "models.DecimalField(max_digits=None, decimal_places=None)")
|
||||
# Guessed arguments, see #5014
|
||||
assertFieldType('decimal_field', "models.DecimalField(max_digits=10, decimal_places=5) "
|
||||
"# max_digits and decimal_places have been guessed, as this database handles decimal fields as float")
|
||||
else:
|
||||
assertFieldType('decimal_field', "models.DecimalField(max_digits=6, decimal_places=1)")
|
||||
assertFieldType('email_field', "models.CharField(max_length=75)")
|
||||
|
|
Loading…
Reference in New Issue