[2.2.x] Fixed #30412 -- Fixed crash when adding check constraints with OR'ed condition on Oracle and SQLite.

Backport of 719b746620 from master
This commit is contained in:
can 2019-04-30 11:20:41 +03:00 committed by Mariusz Felisiak
parent 54fcdf168a
commit 58391b4d16
4 changed files with 42 additions and 1 deletions

View file

@ -23,6 +23,21 @@ class TestQuery(SimpleTestCase):
self.assertEqual(lookup.rhs, 2)
self.assertEqual(lookup.lhs.target, Author._meta.get_field('num'))
def test_simplecol_query(self):
query = Query(Author)
where = query.build_where(Q(num__gt=2, name__isnull=False) | Q(num__lt=F('id')))
name_isnull_lookup, num_gt_lookup = where.children[0].children
self.assertIsInstance(num_gt_lookup, GreaterThan)
self.assertIsInstance(num_gt_lookup.lhs, SimpleCol)
self.assertIsInstance(name_isnull_lookup, IsNull)
self.assertIsInstance(name_isnull_lookup.lhs, SimpleCol)
num_lt_lookup = where.children[1]
self.assertIsInstance(num_lt_lookup, LessThan)
self.assertIsInstance(num_lt_lookup.rhs, SimpleCol)
self.assertIsInstance(num_lt_lookup.lhs, SimpleCol)
def test_complex_query(self):
query = Query(Author)
where = query.build_where(Q(num__gt=2) | Q(num__lt=0))