Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#1819 closed (fixed)

[patch] Inspectdb generates CharFields with null

Reported by: remco@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: dev
Severity: minor Keywords:
Cc: mir@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Inspectdb generates CharFields with null=true for mysql tables that have attributes which allow Null values. This is not Django convention:

"null

If True, Django will store empty values as NULL in the database. Default is False.

Note that empty string values will always get stored as empty strings, not as NULL -- so use null=True for non-string fields such as integers, booleans and dates.

Avoid using null on string-based fields such as CharField and TextField unless you have an excellent reason. If a string-based field has null=True, that means it has two possible values for "no data": NULL, and the empty string. In most cases, it's redundant to have two possible values for "no data;" Django convention is to use the empty string, not NULL."

-- source: http://www.djangoproject.com/documentation/model_api/

Attachments (1)

textfield_null.diff (476 bytes ) - added by mir@… 19 years ago.
patch

Download all attachments as: .zip

Change History (4)

comment:1 by mir@…, 19 years ago

Cc: mir@… added
Summary: Inspectdb generates CharFields with null=true while this is not Django convention[patch] Inspectdb generates CharFields with null=true while this is not Django convention
Version: magic-removalSVN

Yes, you're right. Here's a patch, worked for me. Can you check it?

by mir@…, 19 years ago

Attachment: textfield_null.diff added

patch

comment:2 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(In [2872]) Fixed #1819 -- inspectdb no longer puts null=True for TextField and CharField. Thanks, mir@…

comment:3 by Go, 18 years ago

Summary: [patch] Inspectdb generates CharFields with null=true while this is not Django convention[patch] Inspectdb generates CharFields with null
Type: defect
Note: See TracTickets for help on using tickets.
Back to Top