Comment (by Daniel Schaffer):
Thanks for that explanation Simon - I wouldn't have guessed this was quite
that complicated an issue, but that all makes sense (and an interesting
read to boot!).
--
Ticket URL: <https://code.djangoproject.com/ticket/33766#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Martin Schmidt):
I have a similar issue with FilteredRelation and joins and traced it back
to a django update from 4.0.3 to 4.0.6.
My guess is that this specific issue was introduced in
https://code.djangoproject.com/ticket/33598
The provided workaround helped me a lot. Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/33766#comment:8>
Comment (by Mariusz Felisiak):
#33929 was closed as a duplicate. We should add tests for #33929 when
resolving this issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/33766#comment:9>
Comment (by Mariusz Felisiak):
#34229 was closed as a duplicate. We should add tests for #34229 when
resolving this issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/33766#comment:10>
Comment (by zhu):
The FilteredRelation cannot resolve itself too.
{{{
def test_ref_self_in_condition(self):
self.assertSequenceEqual(
Author.objects.annotate(
the_book=FilteredRelation(
"book",
condition=Q(
name=F('book__title'),
),
),
)
.filter(
the_book__isnull=False,
),
[],
)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33766#comment:11>
* cc: Sarah Boyce (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33766#comment:12>
Comment (by Francesco Panico):
Could this bug be resolved after fixing [[ticket:34362]]? In the PR I
encountered exactly this error
--
Ticket URL: <https://code.djangoproject.com/ticket/33766#comment:13>
* cc: Francesco Panico (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33766#comment:14>
* owner: nobody => Simon Charette
* status: new => assigned
* has_patch: 0 => 1
Comment:
Francesco, it's the other way around, fixing this bug is required to
address #34362.
--
Ticket URL: <https://code.djangoproject.com/ticket/33766#comment:15>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/33766#comment:16>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"d660cee5bc68b597503c2a16f3d9928d52f93fb4" d660cee5]:
{{{
#!CommitTicketReference repository=""
revision="d660cee5bc68b597503c2a16f3d9928d52f93fb4"
Fixed #33766 -- Resolved FilteredRelation.condition at referencing time.
The previous implementation resolved condition at Join compilation time
which required introducing a specialized expression resolving mode to
alter the join reuse logic solely during that phase.
FilteredRelation.condition is now resolved when the relation is first
referenced which maintains the existing behavior while allowing the
removal of the specialized resolving mode and address an issue where
conditions couldn't spawn new joins.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33766#comment:17>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"83c9765f45e4622e4a5af3adcd92263a28b13624" 83c9765]:
{{{
#!CommitTicketReference repository=""
revision="83c9765f45e4622e4a5af3adcd92263a28b13624"
Refs #33766 -- Removed sql.Query.build_filtered_relation_q().
It was a copy of sql.Query._add_q that avoided JOIN updates.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33766#comment:19>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"1a13161eab2d040990734f80b3eedea354f6a4ba" 1a13161]:
{{{
#!CommitTicketReference repository=""
revision="1a13161eab2d040990734f80b3eedea354f6a4ba"
Refs #33766 -- Removed unused Join.equals().
It's unused now that the specialized FilteredRelation.as_sql logic is
no more.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33766#comment:18>