Re: [Django] #15040: Boolean fields return 0 and 1 when loaded through select_related

20 views
Skip to first unread message

Django

unread,
Feb 27, 2012, 7:57:58 AM2/27/12
to django-...@googlegroups.com
#15040: Boolean fields return 0 and 1 when loaded through select_related
-------------------------------------+-------------------------------------
Reporter: homm | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.2
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by ramiro):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/15040#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 22, 2012, 12:27:42 PM8/22/12
to django-...@googlegroups.com
#15040: Boolean fields return 0 and 1 when loaded through select_related
-------------------------------------+-------------------------------------
Reporter: homm | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.2
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by anonymous):

I just spent a ton of time debugging to figure out what this bug is. It
causes ModelForms to have checkboxes that are all checked.

--
Ticket URL: <https://code.djangoproject.com/ticket/15040#comment:7>

Django

unread,
Aug 22, 2012, 12:31:27 PM8/22/12
to django-...@googlegroups.com
#15040: Boolean fields return 0 and 1 when loaded through select_related
-------------------------------------+-------------------------------------
Reporter: homm | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.2
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by benjaoming):

* cc: benjaoming@… (added)


Comment:

*bump* there is a patch for this! It even contains a very neat set of
tests. Can it be merged and the bug closed? :)

--
Ticket URL: <https://code.djangoproject.com/ticket/15040#comment:8>

Django

unread,
Oct 22, 2012, 7:13:46 AM10/22/12
to django-...@googlegroups.com
#15040: Boolean fields return 0 and 1 when loaded through select_related
-------------------------------------+-------------------------------------
Reporter: homm | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.4

(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by anonymous):

* version: 1.2 => 1.4


Comment:

In my opinion this is a fairly significant issue. I spent all morning
trying to figure out why a ModelForm (which was working perfectly locally
on SQLite) had broken checkbox fields when deployed with a mysql backend.

{{{
parent = ParentModel.objects.select_related('child').get(pk=id)
# BooleanFields won't work with this form if using MySQL because their
values are rendered as ints due to select_related()
child_form = ChildModelForm(instance=parent.child)
}}}

If there's no easy fix to this in Django itself I think there should at
least be a warning in the documentation letting users know of this issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/15040#comment:9>

Django

unread,
Oct 25, 2012, 7:31:52 PM10/25/12
to django-...@googlegroups.com
#15040: Boolean fields return 0 and 1 when loaded through select_related
-------------------------------------+-------------------------------------
Reporter: homm | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.4
(models, ORM) | Resolution: fixed

Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Luke Plant <L.Plant.98@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"f3a2bcdee906f7ca1434b6275fdc09b3a454cf46"]:
{{{
#!CommitTicketReference repository=""
revision="f3a2bcdee906f7ca1434b6275fdc09b3a454cf46"
Fixed #15040 - Boolean fields return 0 and 1 when loaded through
select_related

Thanks to homm for the report and ramiro for the patch.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/15040#comment:10>

Django

unread,
Oct 25, 2012, 7:37:55 PM10/25/12
to django-...@googlegroups.com
#15040: Boolean fields return 0 and 1 when loaded through select_related
-------------------------------------+-------------------------------------
Reporter: homm | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 1.4
(models, ORM) | Resolution: fixed
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Luke Plant <L.Plant.98@…>):

In [changeset:"142f69eb8c79ea5a54799354231b219f7c53b1cc"]:
{{{
#!CommitTicketReference repository=""
revision="142f69eb8c79ea5a54799354231b219f7c53b1cc"
[1.5.x] Fixed #15040 - Boolean fields return 0 and 1 when loaded through
select_related

Thanks to homm for the report and ramiro for the patch.

Backport of f3a2bcdee906f7ca1434b6275fdc09b3a454cf46 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/15040#comment:11>

Django

unread,
Apr 5, 2013, 4:52:47 PM4/5/13
to django-...@googlegroups.com
#15040: Boolean fields return 0 and 1 when loaded through select_related
-------------------------------------+-------------------------------------
Reporter: homm | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 1.4
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by anonymous):

* status: closed => new
* resolution: fixed =>


Comment:

I am having this problem in 1.5.1 -- 0 when using select related, but
False when not. I am using mysql.

--
Ticket URL: <https://code.djangoproject.com/ticket/15040#comment:12>

Django

unread,
Apr 5, 2013, 5:02:04 PM4/5/13
to django-...@googlegroups.com
#15040: Boolean fields return 0 and 1 when loaded through select_related
-------------------------------------+-------------------------------------
Reporter: homm | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.4
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by anonymous):

The problem only occurs when using .defer()

--
Ticket URL: <https://code.djangoproject.com/ticket/15040#comment:13>

Django

unread,
Oct 4, 2013, 3:37:13 PM10/4/13
to django-...@googlegroups.com
#15040: Boolean fields return 0 and 1 when loaded through select_related
-------------------------------------+-------------------------------------
Reporter: homm | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.4
(models, ORM) | Resolution: fixed

Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* status: new => closed
* resolution: => fixed


Comment:

@anonymous, please open a new ticket with a test case if you can reproduce
the issue on master. I tried the attached test based on your vague
description but it passes on master and 1.5.x.

--
Ticket URL: <https://code.djangoproject.com/ticket/15040#comment:14>

Django

unread,
Oct 4, 2013, 3:59:55 PM10/4/13
to django-...@googlegroups.com
#15040: Boolean fields return 0 and 1 when loaded through select_related
-------------------------------------+-------------------------------------
Reporter: homm | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 1.4
(models, ORM) | Resolution: fixed
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by akaariai):

I am pretty sure this one was fixed in #21203 and #21126, both of which
got backpatched to 1.5.

--
Ticket URL: <https://code.djangoproject.com/ticket/15040#comment:15>

Django

unread,
Nov 17, 2014, 6:19:58 PM11/17/14
to django-...@googlegroups.com
#15040: Boolean fields return 0 and 1 when loaded through select_related
-------------------------------------+-------------------------------------
Reporter: homm | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 1.4
(models, ORM) | Resolution: fixed
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by kylegibson):

I apologise if this isn't the proper place for this comment, but what
would it take to get this fix backpatched to 1.4?

--
Ticket URL: <https://code.djangoproject.com/ticket/15040#comment:16>

Django

unread,
Nov 17, 2014, 6:23:21 PM11/17/14
to django-...@googlegroups.com
#15040: Boolean fields return 0 and 1 when loaded through select_related
-------------------------------------+-------------------------------------
Reporter: homm | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 1.4
(models, ORM) | Resolution: fixed
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by carljm):

Replying to [comment:16 kylegibson]:


> I apologise if this isn't the proper place for this comment, but what
would it take to get this fix backpatched to 1.4?

I'm afraid it won't be. 1.4 is in security-fix-only mode.

--
Ticket URL: <https://code.djangoproject.com/ticket/15040#comment:17>

Reply all
Reply to author
Forward
0 new messages