MCPcopy
hub / github.com/django/django / __xor__

Method __xor__

django/db/models/query.py:522–539  ·  view source on GitHub ↗
(self, other)

Source from the content-addressed store, hash-verified

520 return combined
521
522 def __xor__(self, other):
523 self._check_operator_queryset(other, "^")
524 self._merge_sanity_check(other)
525 if isinstance(self, EmptyQuerySet):
526 return other
527 if isinstance(other, EmptyQuerySet):
528 return self
529 query = (
530 self
531 if self.query.can_filter()
532 else self.model._base_manager.filter(pk__in=self.values("pk"))
533 )
534 combined = query._chain()
535 combined._merge_known_related_objects(other)
536 if not other.query.can_filter():
537 other = other.model._base_manager.filter(pk__in=other.values("pk"))
538 combined.query.combine(other.query, sql.XOR)
539 return combined
540
541 ####################################
542 # METHODS THAT DO DATABASE QUERIES #

Callers

nothing calls this directly

Calls 8

_merge_sanity_checkMethod · 0.95
valuesMethod · 0.95
can_filterMethod · 0.80
_chainMethod · 0.80
combineMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected