Repository navigation
Fix SQL and Python parity for CEL member counts of at least zero - #615
Conversation
gonzalesedwin1123
left a comment
There was a problem hiding this comment.
Thanks for the report and the fix. The bug in #614 is real, and the change is small and correct. Reviewed at 815530b.
What I checked
- SQL path:
GROUP BY ... HAVING COUNT(*) >= 0over membership rows cannot return a parent with no rows, so thecount >= 0shortcut is the right shape. It returns parent IDs through the existingselect_ids_from_domainhelper, and the callers still AND the profile's base domain and run the result through an ORM search, so record rules and the active filter keep applying. - Python path: with the new condition, zero-count parents are considered even when no base domain is set. Note this is broader than the title: it also changes
count == 0,< N,<= Nand!= Nwithout a base domain, which previously dropped empty parents whenever at least one membership row matched. I think that is the correct behaviour, but please mention it in the PR description so the description matches the diff. - The docstring fix is right; the old text claimed a
NOT INsubquery forcount == 0that the code never built. - Tests: the seeded generator is deterministic, the ages are well clear of the 5 and 65 boundaries, and the 96 rules / 18 households match the description.
load_profilereturns a deep copy, so overridingbase_domainin the test does not leak into other tests.
Requested before merge
- Bump
spp_cel_domainin__manifest__.pyto19.0.2.1.1and add a matching### 19.0.2.1.1entry at the top ofreadme/HISTORY.md(a- fix(executor): ...bullet). Every code fix in this repo needs both. Please do not regenerateREADME.rst/static/description/index.htmllocally: the CI pre-commit job prints the exact expected diff for those, and that output is what should be committed. Heads-up that #535 also targets 2.1.1 and touchescel_executor.py; whichever merges second will renumber.
Suggested, not blocking
- A test for the broadened Python behaviour, for example
members.count(m, true) == 0withbase_domain = [], asserting that a household with no members is returned. The generated test only uses operators that take the SQL path, so that branch is currently uncovered. type(rhs) in (int, float)could beisinstance(rhs, (int, float)) and not isinstance(rhs, bool)if excluding booleans is the intent; fine to leave as is.
CI has not run on this PR yet because workflows on fork PRs need a maintainer's approval, so I have not seen the suite pass. A maintainer will approve the run.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 19.0 #615 +/- ##
==========================================
- Coverage 77.17% 76.05% -1.12%
==========================================
Files 727 759 +32
Lines 47006 52762 +5756
==========================================
+ Hits 36276 40129 +3853
- Misses 10730 12633 +1903
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Thanks for the quick turnaround. All three review points are addressed, and the new One note on the extra commit on your branch: I pushed 67efee7, which regenerates For future PRs: don't regenerate them locally, because local tool versions render slightly differently from CI. Push the fragment change, let the pre-commit job fail, and commit exactly the diff it prints at the end of its log. CI is green on 67efee7. Please pull before pushing anything else to this branch. |
gonzalesedwin1123
left a comment
There was a problem hiding this comment.
Re-reviewed at 67efee7. All requested changes are in: version bump to 19.0.2.1.1 with a matching HISTORY entry, a test for the == 0 Python path without a base domain, and the isinstance check. CI is green. Thanks for the fix.
Why is this change needed?
members.count(m, true) >= 0should match any household in the candidate set. The SQL fast path usedGROUP BYover membership rows, which excluded households with zero matching members. The Python fallback returned them when the profile supplied a base domain.How was the change implemented?
For
count >= 0, the SQL path selects parent IDs directly and the caller still applies its base domain and record rules. With no base domain, Python now includes parents with zero matching memberships whenever zero satisfies the comparison. This coverscount == 0,count < N,count <= N, andcount != Nwhere applicable. Previously, a matching membership on any parent could cause those zero-count parents to be dropped.New tests
members.count(m, true) >= 0through both paths.count >= 0in a profile without a base domain.members.count(m, true) == 0includes an empty household and excludes a populated household.Tests run locally
Odoo 19 Community and PostgreSQL 16.14. The 648 existing
spp_cel_domaintests passed on the original executor. The minimal regression and generated test both failed before the fix. The full suite passed with the fix (652 tests, zero failures or errors).How to test manually
Run the Odoo shell reproduction from the issue. Both paths now return the empty household with a count of
1.Closes #614.