#11654 closed (wontfix)
Allow query objects to be passed into the extra ORM method
Reported by: | ErikW | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | |
Severity: | Keywords: | extra | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It would be really handy (and probably also make ORM querys that use extra more portable) if extra() allowed "query" objects to be passed in addition to raw SQL.
For example:
In addition to:
Blog.objects.all().extra(select={'blah': 'SELECT foo FROM bar WHERE created < NOW()'})
accept:
Blog.objects.all().extra(select={'blah': Bar.objects.filter(created__lt=datetime.datetime.now().values('foo').query})
Seems like a great addition to me. :-)
Note:
See TracTickets
for help on using tickets.
This is already possible using query.as_sql(), however that's an internal. In any event extra() is a down to the metal pure SQL thing, we aren't going to build up a ton of infastructure around it.