'Ensure that extra WHERE clauses get correctly ANDed, even when they
contain OR operations.'

def test_regression_17877(self):

    t = TestObject(first=u'a', second=u'a', third=u'a')
    t.save()
    t = TestObject(first=u'b', second=u'a', third=u'a')
    t.save()
    t = TestObject(first=u'a', second=u'a', third=u'b')
    t.save()
    t = TestObject(first=u'b', second=u'a', third=u'b')
    t.save()
    t = TestObject(first=u'b', second=u'b', third=u'a')
    t.save()
    t = TestObject(first=u'a', second=u'b', third=u'b')
    t.save()
    self.assertQuerysetEqual(TestObject.objects.extra(where=[u"first    =    'a'    OR    second    =    'a'", u"third    =    'a'"]), [u'<TestObject:    TestObject:    a,a,a>', u'<TestObject:    TestObject:    b,a,a>'], ordered=False)
