Skip to content

.filter with wrong fields does not fail if .annotate is used #2307

Closed
@sobolevn

Description

@sobolevn
- case: repro
  main: |
    from django.db import models
    from myapp.models import Blog

    Blog.objects.annotate(
        annotate_entries=models.Count("entry"),
    ).filter(annotate_wrong__gt=5)

    Blog.objects.alias(
        alias_entries=models.Count("entry"),
    ).annotate(
        annotate_entries=models.Count("entry"),
    ).filter(alias_wrong__gt=5, annotate_wrong__gt=5)
  installed_apps:
    - myapp
  files:
    - path: myapp/__init__.py
    - path: myapp/models.py
      content: |
        from django.db import models

        class Blog(models.Model):
            pass

        class Entry(models.Model):
            blog = models.ForeignKey(Blog, on_delete=models.CASCADE)

This does not look right.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions