Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
sobolevn opened this issue Aug 1, 2024 · 0 comments · Fixed by #2332
Closed

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

sobolevn opened this issue Aug 1, 2024 · 0 comments · Fixed by #2332
Labels
bug Something isn't working

Comments

@sobolevn
Copy link
Member

sobolevn commented Aug 1, 2024

- 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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

1 participant