Skip to content

Commit 592291d

Browse files
refactor: Improve field operation detection in query builder
- Refactored `_detect_field_operation` method in `_MetodQueryBuilder` to streamline the detection of field operations. - Ensured that the `_not_in` suffix is prioritized to prevent false positives when matching with `_in`. - Cleaned up unnecessary comments and improved code clarity for better maintainability.
1 parent 3ba28d5 commit 592291d

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

py_spring_model/py_spring_model_rest/service/curd_repository_implementation_service/method_query_builder.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ def parse_query(self) -> _Query:
111111
],
112112
field_operations=field_operations,
113113
)
114-
115114
def _detect_field_operation(self, field: str) -> FieldOperation | None:
116115
"""
117116
Detect field operation based on field suffix.
@@ -122,11 +121,8 @@ def _detect_field_operation(self, field: str) -> FieldOperation | None:
122121
Returns:
123122
FieldOperation if detected, None if no operation suffix found
124123
"""
125-
# Check for _not_in first (longer suffix) to avoid matching _in
126-
if field.endswith("_not_in"):
127-
return FieldOperation.NOT_IN
128-
129124
operation_suffixes = {
125+
"_not_in": FieldOperation.NOT_IN, # _not_in should be check before _in for preventing false positive
130126
"_in": FieldOperation.IN,
131127
"_gt": FieldOperation.GREATER_THAN,
132128
"_gte": FieldOperation.GREATER_EQUAL,

0 commit comments

Comments
 (0)