Hello,
I would like some help from the core guys. I'm getting an error while
executing the following query (the objective of this query is basically get
the last created employee for each company):
*Company.objects.annotate(Max('employee__pk')).filter(employee__pk=F('employee__pk__max'))*
The error follows:
*OperationalError: (1054, "Unknown column 'T3.id' in 'having clause'")*
Not sure if my query is correct in the Django perspective but it's look OK
when looking at DB level. There are some gotchas I noticed:
1 - It works in SQLite.
2 - If I change the field (eg: `*employee__pk*` to `*employee__created`*)
it works fine. It seems to crash only when using PK.
4 - The generated SQL does not include the `T3.id` in the `SELECT` clause.
If I add it through the `QuerySet#extras` the problem goes away.
Thanks in advance,
Paulo Poiati
blog.paulopoiati.com
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/CABqSV%3DKz3CLzbQqxGOZ5FWtiuSy6soRi_3BXL0qpjtBFUSOh5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.