MCPcopy
hub / github.com/django/django / test_complex_query

Method test_complex_query

tests/queries/test_query.py:54–67  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

52 self.assertIsNone(num_lt_lookup.lhs.alias)
53
54 def test_complex_query(self):
55 query = Query(Author)
56 where = query.build_where(Q(num__gt=2) | Q(num__lt=0))
57 self.assertEqual(where.connector, OR)
58
59 lookup = where.children[0]
60 self.assertIsInstance(lookup, GreaterThan)
61 self.assertEqual(lookup.rhs, 2)
62 self.assertEqual(lookup.lhs.target, Author._meta.get_field("num"))
63
64 lookup = where.children[1]
65 self.assertIsInstance(lookup, LessThan)
66 self.assertEqual(lookup.rhs, 0)
67 self.assertEqual(lookup.lhs.target, Author._meta.get_field("num"))
68
69 def test_multiple_fields(self):
70 query = Query(Item, alias_cols=False)

Callers

nothing calls this directly

Calls 4

build_whereMethod · 0.95
QueryClass · 0.90
QClass · 0.90
get_fieldMethod · 0.45

Tested by

no test coverage detected