Whole file

kayak/pypika

The author described this change as fix(terms): fixed EmptyCriterion bug with ComplexCriterion (#732). It counts as a record because the check below fails on the code as it stood at ea9cc5b22 and passes on 12a8f336e, with nothing else changed between the two runs.

Fix saved2023-09-22
Sharing licenceApache-2.0 · LICENSE.txt
Change size+9 0

What the code was meant to do, written into the code itself as a save note

fix(terms): fixed EmptyCriterion bug with ComplexCriterion (#732)

The change

486486
487487 class Criterion(Term):
488488 def __and__(self, other: Any) -> "ComplexCriterion":
489+ if isinstance(other, EmptyCriterion):
490+ return self
489491 return ComplexCriterion(Boolean.and_, self, other)
490492
491493 def __or__(self, other: Any) -> "ComplexCriterion":
494+ if isinstance(other, EmptyCriterion):
495+ return self
492496 return ComplexCriterion(Boolean.or_, self, other)
493497
494498 def __xor__(self, other: Any) -> "ComplexCriterion":
499+ if isinstance(other, EmptyCriterion):
500+ return self
495501 return ComplexCriterion(Boolean.xor_, self, other)
496502
497503 @staticmethod
531537
532538 def __xor__(self, other: Any) -> Any:
533539 return other
540+
541+ def __invert__(self) -> Any:
542+ return self
534543
535544
536545 class Field(Criterion, JSON):

The check that tells the two apart

failpass·pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion

Check file pypika/tests/test_criterions.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itea9cc5b222dd9f056d072ceebce25f5980d4c2dd
Broken version dated2023-09-22
Modulepypika.terms
Units changedCriterion, EmptyCriterion
Fingerprintf2f8f24411b29dd3
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in kayak/pypika