#18378: Q() combined with annotate() can produce bad SQL -------------------------------------+------------------------------------- Reporter: joseph.helfer@… | Owner: nobody Type: Bug | Status: closed Component: Database layer | Version: 1.3 (models, ORM) | Resolution: Severity: Normal | worksforme Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Ian Foote):
* status: new => closed * resolution: => worksforme Comment: I looked into this and couldn't replicate the problem on the {{{master}}} branch. I assume the bug has been fixed in the 6 years since being reported. I used the {{{Book}}} model in {{{tests.annotations.models}}} to write this query: {{{#!python qs = Book.objects.annotate(author_count=Count('authors')).filter( Q(author_count__gt=0) | Q(publisher__name='Sams') ) }}} This gave reasonable results when running the test on mysql. -- Ticket URL: <https://code.djangoproject.com/ticket/18378#comment:7> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/081.02a9f7f9cf192d0c81f86013e2de0ae8%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.