You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A general workaround for this bug is to use F expressions:
from django.db.models import F
q1 = ModelOne.objects.filter(flags=F('flags').bitor(ModelOne.flags.flag))
q2 = ModelTwo.objects.filter(id__in=q1)
This will produce the correct SQL.
It's also worth noting that this bug only affects Django >1.6 when multiple table aliases are in use (e.g. joins). I've tried debugging this issue further and I wouldn't be surprised if this is actually a bug in Django.
The produced sql will be like this,
From the sql, the condition in sub-query is refer to "model_two" not U0.
This will produce invalid reference table in the query.
The text was updated successfully, but these errors were encountered: