Ticket #8802: django-mysql-bool-note.diff

File django-mysql-bool-note.diff, 921 bytes (added by Alex Gaynor, 16 years ago)
  • docs/ref/databases.txt

    diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
    index 66bb836..daa555e 100644
    a b storage engine, you have a couple of options.  
    228228
    229229.. _AlterModelOnSyncDB: http://code.djangoproject.com/wiki/AlterModelOnSyncDB
    230230
     231BooleanFields
     232-------------
     233
     234In Django when you use a :class:`~django.db.models.fields.BooleanField` with
     235MySQL Django will actually create an integer column.  This means that when
     236retrieving a value you will get `1` and `0` instead of `True` and `False`.  This
     237is usually not an issue in your code, because in Python they are completely
     238equal(bool is actually a subclass of int).  However it does mean that if you
     239want to write portable tests you should test for equality, not output::
     240    # bad
     241    >>> my_obj.bool
     242    True
     243   
     244    # good
     245    >>> my_obj.bool == True
     246    True
    231247
    232248.. _oracle-notes:
    233249
Back to Top