Ticket #7312: 7312.regressiontest.diff

File 7312.regressiontest.diff, 934 bytes (added by anonymous, 7 years ago)
  • tests/regressiontests/queries/models.py

     
    134134    def __unicode__(self):
    135135        return self.data
    136136
     137class CustomQ(object):
     138    def __init__(self, *args, **kwargs):
     139        self.args = args
     140        self.kwargs = kwargs
     141    def add_to_query(self, query, aliases):
     142        query.add_q(Q(*self.args, **self.kwargs))
    137143
    138144__test__ = {'API_TESTS':"""
    139145>>> t1 = Tag(name='t1')
     
    701707>>> mm = ManagedModel.objects.create(data='mm1', tag=t1, is_public=True)
    702708>>> ManagedModel.objects.update(data='mm')
    703709
     710Bug #7312
     711>>> Item.objects.complex_filter(CustomQ(tags=t1)).order_by('name')
     712[<Item: one>, <Item: two>]
     713>>> Item.objects.complex_filter(CustomQ(tags=t1)).filter(Q(tags=t2))
     714[<Item: one>]
     715
    704716"""}
Back to Top