﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
7231	"New ""join"" parameter for the ""extra"" QuerySet method"	"Davide ""Design"" Muzzarelli"	nobody	"This ""join"" parameter for the ""extra"" !QuerySet method add the possibility to use any join type.

The implementation is simple and resolve just the base needs of custom SQL queries without lose the capabilities of the Django ORM.

This feature could open the possibility of the fast translation of models and many other uses like speed optimizations in views.

An example from the News application:
{{{
class News(models.Model):
    pub_date = models.DateField()

class NewsTranslation(model.Model):
    title = models.CharField(max_length=128)
    body = models.TextField()
    language_code = models.CharField(max_length=2, core=True)
    news = models.ForeignKey(News)
}}}

Getting all the news translated in english:
{{{
News.objects.extra(
    select={'title': 'news_newstranslation.title', 'body': 'news_newstranslation.body'},
    join=['LEFT JOIN news_newstranslation ON (news_news.id = news_newstranslation.news_id AND news_newstranslation.language_code = \'en\')']
)
}}}

The result of the query is a list of News with ""title"" and ""body"" attributes. The News without translation are also correctly fetched with the attributes ""title"" and ""body"" set at None.

The patch is post queryset-refactor."	New feature	closed	Database layer (models, ORM)	dev	Normal	wontfix	queryset extra left join	elsdoerfer@… sciyoshi@… ssadler@… bendavis78@… simonotron real.human@…	Design decision needed	1	1	1	1	0	0
