Repository navigation
Add opt-in grouping for ORM filters - #324
UmutAlisoglu wants to merge 1 commit into
Conversation
Hi @UmutAlisoglu thx for the PR (and explicit note about AI usage). This looks like solid enhancement (yeah, "opt-in" not backward breaking, as envisioned in #280). I understand your/agent logic for ast module in test. Yeah, makes sense and will stay. But for readability reasons and perhaps even possible encoding problems, the parameterized tests could actually also have the hardcoded expected URLs - not as "rather than only" but as "addition to ast". |
721b960 to
365a4aa
Compare
|
Thanks. I kept the AST checks and added explicit expected filter strings and full encoded URLs to each parameterized case. The tests also execute mocked requests and check the actual URL, including a Unicode case. All 312 tests pass locally. |
thx. pls resolve the conflict around changelog from different PR merged. funny, around similar area. |
phanak-sap
left a comment
There was a problem hiding this comment.
Jumping between PRs that appeared past two days I have read through this several time. I do not see any apparent problem, I like that the default is False so no breaking changes for current users, docs and test are OK.
Checked with AI tools as well.
|
I have a itch/gut feeling that more complex test cases for multiple AND/OR/Parenthesis could be added, but that can be safely part of separate PR anyway, due hiding essentially behind a feature flag. |
Group field lookups, Q arguments and preceding chained filters only when group=True. Retain default query serialization and test selected rows with an independent boolean parser. Follow the approach suggested by phanak-sap in SAP#280, originally reported by developer992.
365a4aa to
60a4db6
Compare
|
Rebased onto current master and kept both changelog entries. All 314 tests and the required Pylint/Flake8 checks pass locally. The conflict is resolved. |
Mixing an ORM
__inlookup or aQexpression containingorwith other filters can select rows that fail the other conditions. For example,ID__in=[2, 3], NameLast='Smith'currently allows ID 2 regardless of its name.This implements the opt-in
group=Trueapproach suggested in #280. It groups individual conditions, Q arguments and the preceding filter on chained calls. Grouping stays disabled by default, and all existing query serialization tests pass. The new option reservesgroupon.filter(); an entity property with that name remains accessible throughQ(group=value).The 14 new cases cover mixed keyword/Q conditions,
__ininside Q, compound OR, AND, chained calls, string replacement, empty input, unchanged legacy output and Unicode encoding. Parameterized cases assert explicit filter strings and fully encoded URLs from mocked HTTP requests, alongside evaluating the selected rows with Python's independent AST parser.Documentation and the Unreleased changelog are updated. Thanks to @developer992 for reporting the problem and @phanak-sap for the opt-in design. Addresses #280; follows up on the closed default-changing proposals #283 and #321.
Validation on Windows / Python 3.11.9:
-Wfails on the same five pre-existing configuration/vendor-page warnings on both original and patched documentation.git diff --checkpasses.AI-assisted with OpenAI Codex, including investigation, implementation and verification.