Django

Code

Changeset 6901

Show
Ignore:
Timestamp:
12/09/07 02:01:26 (7 months ago)
Author:
mtredinnick
Message:

queryset-refactor: Added a test to show that various Q() combinations work when the same field with different lookup types are combined. Refs #4289.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/queryset-refactor/tests/regressiontests/queries/models.py

    r6867 r6901  
    8080    def __unicode__(self): 
    8181        return self.title 
     82 
     83class Number(models.Model): 
     84    num = models.IntegerField() 
     85 
     86    def __unicode__(self): 
     87        return unicode(self.num) 
    8288 
    8389# Some funky cross-linked models for testing a couple of infinite recursion 
     
    155161>>> c2.save() 
    156162 
     163>>> n1 = Number(num=4) 
     164>>> n1.save() 
     165>>> n2 = Number(num=8) 
     166>>> n2.save() 
     167>>> n3 = Number(num=12) 
     168>>> n3.save() 
     169 
    157170Bug #1050 
    158171>>> Item.objects.filter(tags__isnull=True) 
     
    199212>>> Author.objects.filter(Q(item__name='three') | Q(report__name='r3')) 
    200213[<Author: a2>] 
     214 
     215Bug #4289 
     216A slight variation on the above theme: restricting the choices by the lookup 
     217constraints. 
     218>>> Number.objects.filter(num__lt=4) 
     219[] 
     220>>> Number.objects.filter(num__gt=8, num__lt=12) 
     221[] 
     222>>> Number.objects.filter(num__gt=8, num__lt=13) 
     223[<Number: 12>] 
     224>>> Number.objects.filter(Q(num__lt=4) | Q(num__gt=8, num__lt=12)) 
     225[] 
     226>>> Number.objects.filter(Q(num__gt=8, num__lt=12) | Q(num__lt=4)) 
     227[] 
     228>>> Number.objects.filter(Q(num__gt=8) & Q(num__lt=12) | Q(num__lt=4)) 
     229[] 
     230>>> Number.objects.filter(Q(num__gt=7) & Q(num__lt=12) | Q(num__lt=4)) 
     231[<Number: 8>] 
    201232 
    202233Bug #6074 
     
    428459>>> Item.objects.extra(select={'count': 'select count(*) from queries_item_tags where queries_item_tags.item_id = queries_item.id'}).filter(count=1) 
    429460[<Item: four>] 
     461 
    430462"""} 
    431463