Code

Opened 5 years ago

Closed 3 years ago

#10786 closed Cleanup/optimization (fixed)

Missing Documentation for new BooleanField limitation

Reported by: robingreen Owned by: sbj3
Component: Core (Other) Version: 1.0
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The recent add to django/trunk/django/core/management/validation.py breaks the Rietveld install process as described in:

http://code.google.com/appengine/articles/pure_django.html

Attachments (1)

fields-10786.diff (764 bytes) - added by sbj3 4 years ago.
Added note to null attribute and BooleanField that NullBooleanField s/b used.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 5 years ago by robingreen

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Here's the error's output:

$ make all
svn co http://rietveld.googlecode.com/svn/trunk/codereview@405
A codereview/intra_region_diff.py
A codereview/middleware.py
A codereview/patching.py
A codereview/views.py
A codereview/init.py
A codereview/models.py
A codereview/library.py
A codereview/engine.py
A codereview/urls.py
A codereview/feeds.py

U codereview

Checked out revision 405.
patch -p0 < patches/library.diff
patching file codereview/library.py
patch -p0 < patches/views.diff
patching file codereview/views.py
patch -p0 < patches/models.diff
patching file codereview/models.py
./manage.py syncdb
Error: One or more models did not validate:
codereview.issue: "local_base": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.issue: "closed": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.message: "draft": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.content: "is_uploaded": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.content: "is_bad": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.content: "file_too_large": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.patch: "is_binary": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.patch: "delta_calculated": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.comment: "left": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.account: "fresh": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.account: "uploadpy_hint": BooleanFields do not accept null values. Use a NullBooleanField instead.

make: * [dev.db] Error 1

comment:2 Changed 5 years ago by robingreen

$ make all
svn co http://rietveld.googlecode.com/svn/trunk/codereview@405
A    codereview/intra_region_diff.py
A    codereview/middleware.py
A    codereview/patching.py
A    codereview/views.py
A    codereview/__init__.py
A    codereview/models.py
A    codereview/library.py
A    codereview/engine.py
A    codereview/urls.py
A    codereview/feeds.py
 U   codereview
Checked out revision 405.
patch -p0 < patches/library.diff
patching file codereview/library.py
patch -p0 < patches/views.diff
patching file codereview/views.py
patch -p0 < patches/models.diff
patching file codereview/models.py
./manage.py syncdb
Error: One or more models did not validate:
codereview.issue: "local_base": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.issue: "closed": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.message: "draft": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.content: "is_uploaded": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.content: "is_bad": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.content: "file_too_large": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.patch: "is_binary": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.patch: "delta_calculated": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.comment: "left": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.account: "fresh": BooleanFields do not accept null values. Use a NullBooleanField instead.
codereview.account: "uploadpy_hint": BooleanFields do not accept null values. Use a NullBooleanField instead.

make: *** [dev.db] Error 1

comment:3 Changed 5 years ago by ubernostrum

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

The error message makes clear what's going on here. BooleanField is only for two-value (true or false) logic. If three-value (true, false or null) logic is needed, use NullBooleanField.

[10456] corrected a bug wherein null=True was allowed on the field definition even though assigning a null value to the field would raise a (run-time) exception. The correct thing for any application which relied on the buggy behavior is simply to use a NullBooleanField instead.

comment:4 Changed 5 years ago by yishai@…

  • Needs documentation set
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Summary changed from "BooleanFields do not accept null values" breaks Rietveld local install. to Missing Documentation for new BooleanField limitation

I am reopening - apologies if this is not the proper way to do this. This change is not documented in the Model field documentation nor in the backwards incompatible changes list (e.g., in the release notes or in the Wiki).

See in particular the (now) misleading text in:
http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.null
And no mention of this limitation in:
http://docs.djangoproject.com/en/dev/ref/models/fields/#booleanfield

comment:5 Changed 5 years ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

This should be in the 1.1 release document.

Changed 4 years ago by sbj3

Added note to null attribute and BooleanField that NullBooleanField s/b used.

comment:6 Changed 4 years ago by sbj3

  • Has patch set
  • Needs documentation unset
  • Owner changed from nobody to sbj3
  • Status changed from reopened to new

comment:7 Changed 3 years ago by SmileyChris

  • Severity set to Normal
  • Type set to Cleanup/optimization

comment:8 Changed 3 years ago by SmileyChris

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

In [16020]:

Fixes #10786 -- Document that NullBooleanField should be used rather than BooleanField with null=True. Thanks sbj3 for the patch.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.