﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19619	BooleanField returning integer instead of Boolean	Brian May	anonymous	"{{{
kg-test-debian ~ # dpkg -l python-django
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                         Version                      Description
+++-============================-============================-========================================================================
ii  python-django                1.4.2-1~bpo60+2              High-level Python web development framework
}}}

My mysql table has:

{{{
CREATE TABLE `auth_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(30) NOT NULL,
  `first_name` varchar(30) NOT NULL,
  `last_name` varchar(30) NOT NULL,
  `email` varchar(75) NOT NULL,
  `password` varchar(128) NOT NULL,
  `is_staff` tinyint(1) NOT NULL,
  `is_active` tinyint(1) NOT NULL,
  `is_superuser` tinyint(1) NOT NULL,
  `last_login` datetime NOT NULL,
  `date_joined` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`)
}}}

{{{
In [10]: from django.contrib.auth import models
In [11]: a = models.User.objects.get(username=""aleks"")
In [12]: a.is_staff
Out[12]: False
}}}

Good. That is what I expected. If I try to retrieve it via another model however:

{{{
In [1]: from karaage.people.models import  Person
In [7]: p = Person.objects.get(user__username='aleks')
In [9]: p.user.is_staff
Out[9]: 0
}}}

(ignore gaps in sequence numbers, I was busy making typos)

OOops. Not good. This 0 means any checkbox set from this field will come out checked. Urgghh.

That person model is just:

{{{
class Person(models.Model):
    user = models.ForeignKey(User, unique=True)
    [... other attributes not used in this test ...]
}}}

I notice ""sqlall"" outputs bool instead of tinyint now in the SQL declaration, however I think it always use to be tinyint. So I think tinyint should still work.

Brian May"	Bug	closed	Database layer (models, ORM)	1.4	Normal	duplicate			Unreviewed	0	0	0	0	0	0
