#35614: SQLCompiler.as_subquery_condition shouldn't modify the query object
-------------------------------------+-------------------------------------
     Reporter:  Csirmaz Bendegúz     |                    Owner:  Csirmaz
                                     |  Bendegúz
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  5.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:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Csirmaz Bendegúz):

 * has_patch:  0 => 1


Old description:

> {{{SQLCompiler.as_subquery_condition}}} modifies the query object.
>
> [https://github.com/django/django/blob/6b3f55446fdc62bd277903fd188a1781e4d92d29/django/db/models/sql/compiler.py#L1619
> django/db/models/sql/compiler.py#L1619]
>
> {{{
> self.query.where.add(RawSQL("%s = %s" % (lhs_sql, rhs), lhs_params), AND)
> }}}
>
> This is unfortunate, because whenever the query is re-compiled, it will
> add another condition.
> I noticed the issue when inspecting {{{.query}}} on a queryset. Each time
> I accessed {{{.query}}}, a new condition appeared.
> An example queryset can be found in test
> {{{MultiColumnFKTests.test_double_nested_query}}}.

New description:

 {{{SQLCompiler.as_subquery_condition}}} modifies the query object.

 
[https://github.com/django/django/blob/6b3f55446fdc62bd277903fd188a1781e4d92d29/django/db/models/sql/compiler.py#L1619
 django/db/models/sql/compiler.py#L1619]

 {{{
 self.query.where.add(RawSQL("%s = %s" % (lhs_sql, rhs), lhs_params), AND)
 }}}

 This is unfortunate, because whenever the query is re-compiled, it adds
 another condition.
 I noticed the issue when inspecting {{{.query}}} on a queryset. Each time
 I accessed {{{.query}}}, a new condition appeared.
 An example queryset can be found in test
 {{{MultiColumnFKTests.test_double_nested_query}}}.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070190c5696b2f-921faa0c-3c1e-4e82-94e5-4919a4a0f91b-000000%40eu-central-1.amazonses.com.

Reply via email to