summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-09-03 06:14:13 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-09-03 06:14:13 +0000
commitfd1d986bb115db44ddd242ca1f7f73c604b60b18 (patch)
tree2398142c4e92265d54a51709d3be7b8a37fbdbaf
parentfd78e89d1e36d954960bf97998254c2a3c5f4d56 (diff)
Fixed #8802 -- Documented MySQL's usage of 1/0 instead of True/False for model
BooleanFields. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8910 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--docs/ref/databases.txt10
-rw-r--r--docs/ref/models/fields.txt13
2 files changed, 23 insertions, 0 deletions
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
index 66bb836ccc..e484dfd29e 100644
--- a/docs/ref/databases.txt
+++ b/docs/ref/databases.txt
@@ -228,6 +228,16 @@ storage engine, you have a couple of options.
.. _AlterModelOnSyncDB: http://code.djangoproject.com/wiki/AlterModelOnSyncDB
+Boolean fields in Django
+-------------------------
+
+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.``.
+
.. _oracle-notes:
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 8412f02d73..97ca83aa52 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -296,6 +296,19 @@ A true/false field.
The admin represents this as a checkbox.
+.. admonition:: MySQL users..
+
+ 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.
+
``CharField``
-------------