A couple of times I've wanted to be able to pass in a sub query as a table in query_set.extra to be able join in some extra information but have been thwarted as the query code always insists on quoting what you pass in as tables to .extra (i.e. it assumes it's always table names).
Back in 2005 with issue #967 someone put in some code to allow this, but as part of qs-rf this was dropped (although the way it was decided whether to quote something back then looks a bit clunky). With postgres at least, if you pass in a subselect to the FROM it has to have an alias, so if the tables argument to extra were to support subselects it would need to allow something like "(SELECT foo FROM blah) AS alias_of_subsel" being passed in. I can't see how to pass in a subselect via .extra with Django 1.1 - if anyone knows how to that would be useful. It seems unnecessarily limiting for .extra not to allow subselects to be passed in where the database engine supports it. A simple fix (although I don't know if it has any bad consequences I can't think of) at least for postgres would be if the backend's quote_name function didn't quote what's passed in if it begins with "(" as subselects in the from in postgres always have to be in parenthesis. I'm going to monkey patch connection.opts.quote_name in my code for now to behave that way. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---