﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33769	F() expressions - OperationalError	Pablo	nobody	"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."	Bug	closed	Documentation	3.2	Normal	duplicate		Mariusz Felisiak	Unreviewed	0	0	0	0	0	0
