MCPcopy
hub / github.com/django/django / test_foreign_key_exclusive

Method test_foreign_key_exclusive

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

Source from the content-addressed store, hash-verified

112 query.build_where(Q(rank__gt=F("author__num")))
113
114 def test_foreign_key_exclusive(self):
115 query = Query(ObjectC, alias_cols=False)
116 where = query.build_where(Q(objecta=None) | Q(objectb=None))
117 a_isnull = where.children[0]
118 self.assertIsInstance(a_isnull, RelatedIsNull)
119 self.assertIsInstance(a_isnull.lhs, Col)
120 self.assertIsNone(a_isnull.lhs.alias)
121 self.assertEqual(a_isnull.lhs.target, ObjectC._meta.get_field("objecta"))
122 b_isnull = where.children[1]
123 self.assertIsInstance(b_isnull, RelatedIsNull)
124 self.assertIsInstance(b_isnull.lhs, Col)
125 self.assertIsNone(b_isnull.lhs.alias)
126 self.assertEqual(b_isnull.lhs.target, ObjectC._meta.get_field("objectb"))
127
128 def test_clone_select_related(self):
129 query = Query(Item)

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