Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#30971 closed Bug (fixed)

Query.resolve_lookup_value coerces value of type list to tuple

Reported by: George Marshall Owned by: George Marshall
Component: Database layer (models, ORM) Version: 3.0
Severity: Release blocker Keywords:
Cc: Simon Charette Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (9)

comment:1 by George Marshall, 5 years ago

Owner: changed from nobody to George Marshall
Status: newassigned

comment:2 by George Marshall, 5 years ago

Has patch: set

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.

comment:3 by Nick Pope, 5 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

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

comment:4 by Mariusz Felisiak, 5 years ago

Needs tests: set

comment:5 by Mariusz Felisiak, 5 years ago

Cc: Simon Charette added

comment:6 by Simon Charette, 5 years ago

The approach seems fine given it's appropriately tested.

comment:7 by Mariusz Felisiak, 5 years ago

Needs tests: unset
Triage Stage: AcceptedReady for checkin

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In fa6076da:

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

Regression in 8a281aa7fe76a9da2284f943964a9413697cff1f.

Backport of 8be79984dce7d819879a6e594ca69c5f95a08378 from master

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 8be79984:

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

Regression in 8a281aa7fe76a9da2284f943964a9413697cff1f.

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