let TranslationQuery inherit indexes (bug 577348)
This commit is contained in:
Родитель
462dc6edcf
Коммит
22256ca0b3
|
@ -13,7 +13,8 @@ class IndexQuerySet(caching.CachingQuerySet):
|
|||
qs.with_index(t1='xxx') => INNER JOIN t1 USE INDEX (`xxx`)
|
||||
"""
|
||||
q = self._clone()
|
||||
q.query = self.query.clone(IndexQuery)
|
||||
if not isinstance(q.query, IndexQuery):
|
||||
q.query = self.query.clone(IndexQuery)
|
||||
q.query.index_map.update(kw)
|
||||
return q
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ from django.db.models.sql import compiler
|
|||
|
||||
from django.utils import translation as translation_utils
|
||||
|
||||
import addons.query
|
||||
|
||||
|
||||
def order_by_translation(qs, fieldname):
|
||||
"""
|
||||
|
@ -50,7 +52,7 @@ def order_by_translation(qs, fieldname):
|
|||
order_by=[prefix + name])
|
||||
|
||||
|
||||
class TranslationQuery(models.query.sql.Query):
|
||||
class TranslationQuery(addons.query.IndexQuery):
|
||||
"""
|
||||
Overrides sql.Query to hit our special compiler that knows how to JOIN
|
||||
translations.
|
||||
|
@ -68,7 +70,7 @@ class TranslationQuery(models.query.sql.Query):
|
|||
return SQLCompiler(self, c.connection, c.using)
|
||||
|
||||
|
||||
class SQLCompiler(compiler.SQLCompiler):
|
||||
class SQLCompiler(addons.query.IndexCompiler):
|
||||
"""Overrides get_from_clause to LEFT JOIN translations with a locale."""
|
||||
|
||||
def get_from_clause(self):
|
||||
|
|
Загрузка…
Ссылка в новой задаче