mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
[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:
parent
54fcdf168a
commit
58391b4d16
4 changed files with 42 additions and 1 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue