[Django] #30971: Query.resolve_lookup_value coerces value of type list to tuple

290 views
Skip to first unread message

Django

unread,
Nov 10, 2019, 3:39:21 AM11/10/19
to django-...@googlegroups.com
#30971: Query.resolve_lookup_value coerces value of type list to tuple
-------------------------------------+-------------------------------------
Reporter: George | Owner: nobody
Marshall |
Type: Bug | Status: new
Component: Database | Version: 3.0
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes introduced in #30687 cause an input value `list` to be coerced to
`tuple` breaking exact value queries. This affects ORM field types that
are dependent on matching input types such as `PickledField`.

The expected iterable return type should match input iterable type.

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

Django

unread,
Nov 10, 2019, 3:41:22 AM11/10/19
to django-...@googlegroups.com
#30971: Query.resolve_lookup_value coerces value of type list to tuple
-------------------------------------+-------------------------------------
Reporter: George Marshall | Owner: George
| Marshall
Type: Bug | Status: assigned
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by George Marshall):

* owner: nobody => George Marshall
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/30971#comment:1>

Django

unread,
Nov 10, 2019, 4:01:47 AM11/10/19
to django-...@googlegroups.com
#30971: Query.resolve_lookup_value coerces value of type list to tuple
-------------------------------------+-------------------------------------
Reporter: George Marshall | Owner: George
| Marshall
Type: Bug | Status: assigned
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by George Marshall):

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/12050

This could potentially use a test case, need some direction on how to
cover this.

I have also included links to my Django library code that was affected by
the change.

https://github.com/georgemarshall/django-
cryptography/blob/789e7a757e01220bc46b17b995bb201cda496ef6/tests/fields/test_pickle.py#L61
https://travis-ci.org/georgemarshall/django-cryptography/jobs/609869188

I am also not sure how the postgres `ArrayField` was not affected by the
tuple coercion.

--
Ticket URL: <https://code.djangoproject.com/ticket/30971#comment:2>

Django

unread,
Nov 10, 2019, 10:53:52 AM11/10/19
to django-...@googlegroups.com
#30971: Query.resolve_lookup_value coerces value of type list to tuple
-------------------------------------+-------------------------------------
Reporter: George Marshall | Owner: George
| Marshall
Type: Bug | Status: assigned
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Nick Pope):

* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

Thanks. I agree that we shouldn't change iterable types unless absolutely
necessary to avoid these subtle bugs.

--
Ticket URL: <https://code.djangoproject.com/ticket/30971#comment:3>

Django

unread,
Nov 11, 2019, 2:26:11 AM11/11/19
to django-...@googlegroups.com
#30971: Query.resolve_lookup_value coerces value of type list to tuple
-------------------------------------+-------------------------------------
Reporter: George Marshall | Owner: George
| Marshall
Type: Bug | Status: assigned
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30971#comment:4>

Django

unread,
Nov 11, 2019, 5:35:30 AM11/11/19
to django-...@googlegroups.com
#30971: Query.resolve_lookup_value coerces value of type list to tuple
-------------------------------------+-------------------------------------
Reporter: George Marshall | Owner: George
| Marshall
Type: Bug | Status: assigned
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* cc: Simon Charette (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/30971#comment:5>

Django

unread,
Nov 11, 2019, 12:52:36 PM11/11/19
to django-...@googlegroups.com
#30971: Query.resolve_lookup_value coerces value of type list to tuple
-------------------------------------+-------------------------------------
Reporter: George Marshall | Owner: George
| Marshall
Type: Bug | Status: assigned
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

The approach seems fine given it's appropriately tested.

--
Ticket URL: <https://code.djangoproject.com/ticket/30971#comment:6>

Django

unread,
Nov 12, 2019, 2:35:00 AM11/12/19
to django-...@googlegroups.com
#30971: Query.resolve_lookup_value coerces value of type list to tuple
-------------------------------------+-------------------------------------
Reporter: George Marshall | Owner: George
| Marshall
Type: Bug | Status: assigned
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin


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

Django

unread,
Nov 13, 2019, 3:22:01 AM11/13/19
to django-...@googlegroups.com
#30971: Query.resolve_lookup_value coerces value of type list to tuple
-------------------------------------+-------------------------------------
Reporter: George Marshall | Owner: George
| Marshall
Type: Bug | Status: closed

Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"fa6076daf460df2c2c5ff9f62862f050bc4427f4" fa6076da]:
{{{
#!CommitTicketReference repository=""
revision="fa6076daf460df2c2c5ff9f62862f050bc4427f4"
[3.0.x] Fixed #30971 -- Prevented Query.resolve_lookup_value() from
coercing list values to tuples.

Regression in 8a281aa7fe76a9da2284f943964a9413697cff1f.

Backport of 8be79984dce7d819879a6e594ca69c5f95a08378 from master
}}}

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

Django

unread,
Nov 13, 2019, 3:22:02 AM11/13/19
to django-...@googlegroups.com
#30971: Query.resolve_lookup_value coerces value of type list to tuple
-------------------------------------+-------------------------------------
Reporter: George Marshall | Owner: George
| Marshall
Type: Bug | Status: closed
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"8be79984dce7d819879a6e594ca69c5f95a08378" 8be79984]:
{{{
#!CommitTicketReference repository=""
revision="8be79984dce7d819879a6e594ca69c5f95a08378"


Fixed #30971 -- Prevented Query.resolve_lookup_value() from coercing list
values to tuples.

Regression in 8a281aa7fe76a9da2284f943964a9413697cff1f.
}}}

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

Reply all
Reply to author
Forward
0 new messages