diff options
| author | Joseph Kocherhans <joseph@jkocherhans.com> | 2010-02-24 17:36:18 +0000 |
|---|---|---|
| committer | Joseph Kocherhans <joseph@jkocherhans.com> | 2010-02-24 17:36:18 +0000 |
| commit | 16fe73d918c8a35f7122aed858312bd3163ac454 (patch) | |
| tree | 06c8c09da94ae39e91735feb581139a2c242a138 /docs | |
| parent | 9f4bf525f887db32b7260909a0140d68910aa042 (diff) | |
Fixed #7190. Boolean fields now return bool values instead of 1 or 0. Thanks, Alex Gaynor.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12578 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/databases.txt | 11 | ||||
| -rw-r--r-- | docs/ref/models/fields.txt | 15 | ||||
| -rw-r--r-- | docs/releases/1.2.txt | 10 |
3 files changed, 19 insertions, 17 deletions
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index afead83d4d..3a7c3eaaca 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -326,12 +326,11 @@ Notes on specific fields Boolean fields ~~~~~~~~~~~~~~ -Since MySQL doesn't have a direct ``BOOLEAN`` column type, Django uses a -``TINYINT`` column with values of ``1`` and ``0`` to store values for the -:class:`~django.db.models.BooleanField` model field. Refer to the documentation -of that field for more details, but usually this won't be something that will -matter unless you're printing out the field values and are expecting to see -``True`` and ``False.``. +.. versionchanged:: 1.2 + +In previous versions of Django when running under MySQL ``BooleanFields`` would +return their data as ``ints``, instead of true ``bools``. See the release +notes for a complete description of the change. Character fields ~~~~~~~~~~~~~~~~ diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index cd66c468dc..d53bef2acf 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -342,18 +342,11 @@ A true/false field. The admin represents this as a checkbox. -.. admonition:: MySQL users.. +.. versionchanged:: 1.2 - A boolean field in MySQL is stored as a ``TINYINT`` column with a value of - either 0 or 1 (most databases have a proper ``BOOLEAN`` type instead). So, - for MySQL, only, when a ``BooleanField`` is retrieved from the database - and stored on a model attribute, it will have the values 1 or 0, rather - than ``True`` or ``False``. Normally, this shouldn't be a problem, since - Python guarantees that ``1 == True`` and ``0 == False`` are both true. - Just be careful if you're writing something like ``obj is True`` when - ``obj`` is a value from a boolean attribute on a model. If that model was - constructed using the ``mysql`` backend, the "``is``" test will fail. - Prefer an equality test (using "``==``") in cases like this. + In previous versions of Django when running under MySQL ``BooleanFields`` + would return their data as ``ints``, instead of true ``bools``. See the + release notes for a complete description of the change. ``CharField`` ------------- diff --git a/docs/releases/1.2.txt b/docs/releases/1.2.txt index b952ec1f6c..703ded3437 100644 --- a/docs/releases/1.2.txt +++ b/docs/releases/1.2.txt @@ -302,6 +302,16 @@ created using ``decorator_from_middleware``. .. _deprecated-features-1.2: +``BooleanField`` on MySQL +-------------------------- + +In previous versions of Django ``BoleanFields`` under MySQL would return their +values as either ``1`` or ``0``, instead of ``True`` or ``False``. For most +people this shouldn't have been a problem because ``bool`` is a subclass of +``int``, however in Django 1.2 MySQL correctly returns a real ``bool``. The +only time this should ever be an issue is if you were expecting printing the +``repr`` of a ``BooleanField`` to print ``1`` or ``0``. + Features deprecated in 1.2 ========================== |
