Ticket #17886: louter.diff
File louter.diff, 4.3 KB (added by , 13 years ago) |
---|
-
django/db/models/sql/query.py
diff -ruN -x settings.py -x '*.pyc' -x '*.stackdump' -x '*.orig' -x '*.rej' ../Django-1.4c1.orig/django/db/models/sql/query.py ../Django-1.4c1/django/db/models/sql/query.py
old new 913 913 # Not all tables need to be joined to anything. No join type 914 914 # means the later columns are ignored. 915 915 join_type = None 916 elif promote or outer_if_first: 916 elif promote or outer_if_first or \ 917 self.alias_map[connection[0]][JOIN_TYPE] == self.LOUTER: 918 # if preceeding alias (connection[0]) has LEFT OUTER JOIN 919 # we should promote it 917 920 join_type = self.LOUTER 918 921 else: 919 922 join_type = self.INNER -
tests/regressiontests/queries/models.py
diff -ruN -x settings.py -x '*.pyc' -x '*.stackdump' -x '*.orig' -x '*.rej' ../Django-1.4c1.orig/tests/regressiontests/queries/models.py ../Django-1.4c1/tests/regressiontests/queries/models.py
old new 346 346 347 347 def __unicode__(self): 348 348 return "one2one " + self.new_name 349 350 class DefinitionOfDoubleCategorizedObject(models.Model): 351 name = models.CharField(max_length=50) 352 353 class CategorizedObject(models.Model): 354 name = models.CharField(max_length=50) 355 category = models.ForeignKey(SimpleCategory) 356 357 class DoubleCategorizedObject(models.Model): 358 name = models.CharField(max_length=50) 359 rel_a = models.ForeignKey(CategorizedObject, null=True, blank=True, related_name="rel_a_double") 360 rel_b = models.ManyToManyField(CategorizedObject, null=True, blank=True, related_name="rel_b_double") 361 definition = models.ForeignKey(DefinitionOfDoubleCategorizedObject) -
tests/regressiontests/queries/tests.py
diff -ruN -x settings.py -x '*.pyc' -x '*.stackdump' -x '*.orig' -x '*.rej' ../Django-1.4c1.orig/tests/regressiontests/queries/tests.py ../Django-1.4c1/tests/regressiontests/queries/tests.py
old new 3 3 import datetime 4 4 import pickle 5 5 import sys 6 import operator 6 7 7 8 from django.conf import settings 8 9 from django.core.exceptions import FieldError … … 18 19 ManagedModel, Member, NamedCategory, Note, Number, Plaything, PointerA, 19 20 Ranking, Related, Report, ReservedName, Tag, TvChef, Valid, X, Food, Eaten, 20 21 Node, ObjectA, ObjectB, ObjectC, CategoryItem, SimpleCategory, 21 SpecialCategory, OneToOneCategory) 22 SpecialCategory, OneToOneCategory, DoubleCategorizedObject, CategorizedObject, 23 DefinitionOfDoubleCategorizedObject) 22 24 23 25 24 26 class BaseQuerysetTest(TestCase): … … 1894 1896 DumbCategory.objects.create() 1895 1897 except TypeError: 1896 1898 self.fail("Creation of an instance of a model with only the PK field shouldn't error out after bulk insert refactoring (#17056)") 1899 1900 class Queries6Test(BaseQuerysetTest): 1901 def setUp(self): 1902 c1 = SimpleCategory.objects.create(name="category1") 1903 c2 = SimpleCategory.objects.create(name="category2") 1904 cat_obj1 = CategorizedObject.objects.create(category=c1, name='cat1') 1905 cat_obj2 = CategorizedObject.objects.create(category=c2, name='cat2') 1906 definition = DefinitionOfDoubleCategorizedObject() 1907 definition.name = 'test def' 1908 definition.save() 1909 double_cat_obj = DoubleCategorizedObject() 1910 double_cat_obj.name = "test obj" 1911 double_cat_obj.rel_a = cat_obj1 1912 double_cat_obj.definition = definition 1913 double_cat_obj.save() 1914 def test_or_query(self): 1915 search_query = 'test def' 1916 or_queries = [ 1917 Q(name__contains= search_query), 1918 Q(doublecategorizedobject__rel_a__name__icontains= search_query), 1919 Q(doublecategorizedobject__rel_a__category__name__icontains = search_query), 1920 Q(doublecategorizedobject__rel_b__name__icontains= search_query), 1921 Q(doublecategorizedobject__rel_b__category__name__icontains = search_query), 1922 ] 1923 q_obj = reduce(operator.or_, or_queries) 1924 qset = DefinitionOfDoubleCategorizedObject.objects.filter(q_obj).select_related() 1925 self.assertTrue(len(qset) == 1) 1926 self.assertNotIn('INNER JOIN', str(qset.query))