#21703: `exclude` query with `F` object across relationship fails -------------------------------+-------------------- Reporter: anonymous | Owner: nobody Type: Uncategorized | Status: new Component: Uncategorized | Version: 1.6 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------+-------------------- Given the following models..
{{{ #!div style="font-size: 80%" Code highlighting: {{{#!python class Owner(models.Model): pass class Thing(models.Model): owner = models.ForeignKey(Owner, related_name='things') date = models.DateField() class Error(models.Model): owner = models.ForeignKey(Owner, related_name='errors') date = models.DateField() }}} }}} The following `exclude` query fails. {{{ #!div style="font-size: 80%" Code highlighting: {{{#!python >>> Error.objects.exclude(owner__things__date=F('date')) Traceback (most recent call last): File "<console>", line 1, in <module> File "/Users/foobar/python-environments/358426a27f281ff5/lib/python2.7 /site-packages/django/db/models/query.py", line 115, in __repr__ data = list(self[:REPR_OUTPUT_SIZE + 1]) File "/Users/foobar/python-environments/358426a27f281ff5/lib/python2.7 /site-packages/django/db/models/query.py", line 140, in __iter__ self._fetch_all() File "/Users/foobar/python-environments/358426a27f281ff5/lib/python2.7 /site-packages/django/db/models/query.py", line 962, in _fetch_all self._result_cache = list(self.iterator()) File "/Users/foobar/python-environments/358426a27f281ff5/lib/python2.7 /site-packages/django/db/models/query.py", line 264, in iterator for row in compiler.results_iter(): File "/Users/foobar/python-environments/358426a27f281ff5/lib/python2.7 /site-packages/django/db/models/sql/compiler.py", line 681, in results_iter for rows in self.execute_sql(MULTI): File "/Users/foobar/python-environments/358426a27f281ff5/lib/python2.7 /site-packages/django/db/models/sql/compiler.py", line 762, in execute_sql cursor.execute(sql, params) File "/Users/foobar/python-environments/358426a27f281ff5/lib/python2.7 /site-packages/django/db/backends/utils.py", line 77, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/Users/foobar/python-environments/358426a27f281ff5/lib/python2.7 /site-packages/django/db/backends/utils.py", line 61, in execute return self.cursor.execute(sql, params) File "/Users/foobar/python-environments/358426a27f281ff5/lib/python2.7 /site-packages/django/db/utils.py", line 93, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/Users/foobar/python-environments/358426a27f281ff5/lib/python2.7 /site-packages/django/db/backends/utils.py", line 61, in execute return self.cursor.execute(sql, params) File "/Users/foobar/python-environments/358426a27f281ff5/lib/python2.7 /site-packages/django/db/backends/sqlite3/base.py", line 489, in execute return Database.Cursor.execute(self, query, params) OperationalError: no such column: U1.id }}} }}} The same query using a `filter` works as expected. This bug is present in `1.5.5`, `1.6.1` and `1.7.dev20131229181725` -- Ticket URL: <https://code.djangoproject.com/ticket/21703> 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/052.60b3b140dec8dd5ac01b5289c4b5fa12%40djangoproject.com. For more options, visit https://groups.google.com/groups/opt_out.