Repository navigation
fix: Skip empty nested filter groups in SQLite and Postgres filter translators - #7052
RaphaelFakhri wants to merge 1 commit into
Conversation
|
LGTM |
|
@RaphaelFakhri could you please rebase this onto the latest master? The branch is currently behind master. |
…anslators Signed-off-by: Raphael Fakhri <[email protected]>
|
Rebased onto the latest master. |
8005ce5 to
8ee447d
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7052 +/- ##
==========================================
+ Coverage 50.97% 51.07% +0.09%
==========================================
Files 455 455
Lines 56994 57002 +8
Branches 8321 8325 +4
==========================================
+ Hits 29055 29111 +56
+ Misses 25954 25899 -55
- Partials 1985 1992 +7
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
What this PR does / why we need it:
SqliteFilterTranslator.translate_compoundandPostgresFilterTranslator.translate_compoundjoin every sub-clause, including the empty clause returned for an empty nestedCompoundFilter. A filter such asand[eq(title, "Title 1"), or[]]becomes(... AND ), and SQLite fails withnear ")": syntax error. Postgres gets the same trailingAND ). A group made only of empty groups becomes( AND )or().This change skips empty sub-clauses and returns an empty clause when none remain, which matches
MilvusFilterTranslator. The callers already treat an empty clause as "no filter".Tests in
tests/unit/test_filter_models.pycheck the generated clause for both translators, run the SQLite clause against an in-memory database, and cover groups made only of empty groups.Which issue(s) this PR fixes:
Fixes #7051
Checks
git commit -s)Testing Strategy
Misc
pytest tests/unit/test_filter_models.py: 4 of the new tests fail without the fix and all 27 pass with it.