async def METHOD_NAME(self):
    category = Case(
        When(intnum__gte=8, then="big"), When(intnum__lte=2, then="small"), default="middle"
    )
    sql = (
        IntFields.all()
        .annotate(category=category)
        .filter(category__in=["big", "small"])
        .values("intnum")
        .sql()
    )
    dialect = self.db.schema_generator.DIALECT
    if dialect == "mysql":
        expected_sql = "SELECT `intnum` `intnum` FROM `intfields` WHERE CASE WHEN `intnum`>=8 THEN 'big' WHEN `intnum`<=2 THEN 'small' ELSE 'middle' END IN ('big','small')"
    else:
        expected_sql = "SELECT \"intnum\" \"intnum\" FROM \"intfields\" WHERE CASE WHEN \"intnum\">=8 THEN 'big' WHEN \"intnum\"<=2 THEN 'small' ELSE 'middle' END IN ('big','small')"
    self.assertEqual(sql, expected_sql)