#12890: extra() tables included twice do not generate aliases ------------------------------------------+--------------------------------- Reporter: semenov | Owner: nobody Status: new | Milestone: Component: Database layer (models, ORM) | Version: 1.1 Keywords: | Stage: Unreviewed Has_patch: 0 | ------------------------------------------+--------------------------------- The documentation at http://docs.djangoproject.com/en/1.1/ref/models/querysets/#extra-select- none-where-none-params-none-tables-none-order-by-none-select-params-none says: "When you add extra tables via the tables parameter, Django assumes you want that table included an extra time, if it is already included. That creates a problem, since the table name will then be given an alias."
That is not true even for simple cases: {{{ #!python print User.objects\ .extra(tables=['auth_user_group'], where=['auth_user.ud=auth_user_group.user_id'])\ .extra(tables=['auth_user_group'], where=['auth_user.ud=auth_user_group.user_id']).all() # crashes with OperationalError(1066, "Not unique table/alias: 'auth_user_group'") }}} This is a real-life example (with different models, of course) from my project. I have to run an extra() query against the same table ''twice'' to achieve the double filtration, but it's not working and doesn't even allow me to specify the aliases manually. A usual double filter() trick would probably work but it is also broken due to #12885. -- Ticket URL: <http://code.djangoproject.com/ticket/12890> Django <http://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 post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.