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.
Projectkayak/pypika
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
| 486 | 486 | ||
| 487 | 487 | class Criterion(Term): | |
| 488 | 488 | def __and__(self, other: Any) -> "ComplexCriterion": | |
| 489 | + | if isinstance(other, EmptyCriterion): | |
| 490 | + | return self | |
| 489 | 491 | return ComplexCriterion(Boolean.and_, self, other) | |
| 490 | 492 | ||
| 491 | 493 | def __or__(self, other: Any) -> "ComplexCriterion": | |
| 494 | + | if isinstance(other, EmptyCriterion): | |
| 495 | + | return self | |
| 492 | 496 | return ComplexCriterion(Boolean.or_, self, other) | |
| 493 | 497 | ||
| 494 | 498 | def __xor__(self, other: Any) -> "ComplexCriterion": | |
| 499 | + | if isinstance(other, EmptyCriterion): | |
| 500 | + | return self | |
| 495 | 501 | return ComplexCriterion(Boolean.xor_, self, other) | |
| 496 | 502 | ||
| 497 | 503 | @staticmethod | |
| ⋯ | |||
| 531 | 537 | ||
| 532 | 538 | def __xor__(self, other: Any) -> Any: | |
| 533 | 539 | return other | |
| 540 | + | ||
| 541 | + | def __invert__(self) -> Any: | |
| 542 | + | return self | |
| 534 | 543 | ||
| 535 | 544 | ||
| 536 | 545 | class Field(Criterion, JSON): | |
The check that tells the two apart
fail→pass·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
- 2024-04-17fix `Field.__init__` (#742)
- 2023-09-26Fix: Allow the usage of `frozenset` in the `isin(...)` and `notin(...)` functions (#744)
- 2021-08-26MySQLQuery
- 2021-01-11Fix empty Postgres array syntax (#539)
- 2021-01-04Fix PostgreSQLQueryBuilder returning clause code causing Py3.9 test failures
- 2020-12-09Fix groupby_alias specified multiple times in kwargs when subqueries are used