Opened 16 years ago

Last modified 12 years ago

#7190 closed

BooleanField does not return <type: 'bool'> — at Initial Version

Reported by: Jeffrey Froman Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: BooleanField, type
Cc: Leo Soto M. Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In some cases, a BooleanField returns an integer instead of a bool. The following example uses a MySQL backend:

# models.py
from django.db import models

class Simple(models.Model):

b = models.BooleanField()


$ ./manage.py syncdb
Creating table djest_simple
$ python
Python 2.5 (r25:51908, Sep 10 2007, 13:30:49)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from djest.models import Simple
>>> simple = Simple.objects.create(b=True)
>>> simple.b
True
>>> simple_2 = Simple.objects.get(pk=simple.pk)
>>> simple_2.b
1

This may not be a problem for normal usage, but makes testing, particularly using doctest, much less elegant.

Change History (1)

by Jeffrey Froman <django.tcijf@…>, 16 years ago

Attachment: boolfield.diff added

patch for django/db/models/fields/init.py

Note: See TracTickets for help on using tickets.
Back to Top