#33769: F() expressions - OperationalError
-----------------------------------------+------------------------
               Reporter:  Pablo          |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  Uncategorized  |        Version:  3.2
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 AppName: shifts

 {{{
 class WorkShift(RegistroMixin):
     season = models.ForeignKey(Season, on_delete=models.CASCADE)
     type = models.ForeignKey('WorkShiftType', null=True,
 on_delete=models.PROTECT)
     horario = models.ForeignKey('HorarioTurno', null=True, blank=True,
 on_delete=models.PROTECT)
     start_date = models.DateTimeField()
     end_date = models.DateTimeField()

 class Season(RegistroMixin):
     chief_tipes = models.ManyToManyField('WorkShiftType')

 }}}



 {{{
 WorkShift.objects.filter(
                           season__in=seasons,
                           type__in=F('season__chief_tipes'),
                           end_date__gte=today
                       ).filter(
             Q(start_date__lte=today) | Q(start_date__lte=today +
 datetime.timedelta(hours=12))
                       )
 }}}



 After upgrade Django 2.2 -> 3.2 this Queryset returns:

 OperationalError at /
 no such table: shifts_season_chief_tipes.workshifttype_id

 The ORM is not correctly constructing the Where statement. In other code
 queries, it does work correctly after migration.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33769>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018135f3b9a5-10476ede-937b-498f-a586-a2dc879dc1e1-000000%40eu-central-1.amazonses.com.

Reply via email to