Opened 3 weeks ago

Closed 7 days ago

#37407 closed Bug (fixed)

UUIDTextMixin.process_rhs() mutates the lookup's rhs in place corrupting repeated compilation

Reported by: Clifford Gama Owned by: Clifford Gama
Component: Database layer (models, ORM) Version: 6.1
Severity: Normal Keywords: mutate
Cc: 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

​django/db/models/lookups.py#L791-L795 reassigns self.rhs directly instead of working on a copy, so recompiling a shared Lookup (e.g. str(queryset.query) called twice, or a cloned queryset) wraps the already-stripped rhs in another Replace() call each time, growing the SQL/params on every pass.

Change History (4)

comment:1 by Clifford Gama, 3 weeks ago

Has patch: set

comment:2 by Sarah Boyce, 8 days ago

Triage Stage: Unreviewed → Accepted

comment:3 by Sarah Boyce, 8 days ago

Triage Stage: Accepted → Ready for checkin

comment:4 by Sarah Boyce <42296566+sarahboyce@…>, 7 days ago

Resolution: → fixed
Status: assigned → closed

In 6de4b35:

Fixed #37407 -- Prevented UUIDTextMixin from mutating the lookup in-place.

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