mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
magic-removal: Fixed #1562 -- Added null and blank detection to 'inspectdb'. Appears only to work for MySQL at this point.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2692 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
93d95b3b10
commit
47333f6d1e
@ -753,6 +753,13 @@ def inspectdb(db_name):
|
|||||||
if att_name == 'id' and field_type == 'AutoField(' and extra_params == {'primary_key': True}:
|
if att_name == 'id' and field_type == 'AutoField(' and extra_params == {'primary_key': True}:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Add 'null' and 'blank', if the 'null_ok' flag was present in the
|
||||||
|
# table description.
|
||||||
|
if row[6]: # If it's NULL...
|
||||||
|
extra_params['blank'] = True
|
||||||
|
if not field_type in ('TextField', 'CharField'):
|
||||||
|
extra_params['null'] = True
|
||||||
|
|
||||||
field_desc = '%s = models.%s' % (att_name, field_type)
|
field_desc = '%s = models.%s' % (att_name, field_type)
|
||||||
if extra_params:
|
if extra_params:
|
||||||
if not field_desc.endswith('('):
|
if not field_desc.endswith('('):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user