Skip to content

Commit 7c79a7e

Browse files
author
Gerit Wagner
committed
generic query: make fields case insensitive
1 parent 8ddab21 commit 7c79a7e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

search_query/query.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,16 @@ def _validate_platform_constraints(self) -> None:
169169
def _set_platform_recursively(self, platform: str) -> None:
170170
"""Set the origin platform for this query node and its children."""
171171
self._platform = platform
172+
self._normalize_field_for_platform()
172173
for child in self._children:
173174
# pylint: disable=protected-access
174175
child._set_platform_recursively(platform)
175176

177+
def _normalize_field_for_platform(self) -> None:
178+
"""Normalize field values based on the current platform."""
179+
if self._field and self._platform == PLATFORM.GENERIC.value:
180+
self._field.value = self._field.value.lower()
181+
176182
@property
177183
def platform(self) -> str:
178184
"""Platform property."""
@@ -318,6 +324,8 @@ def field(self) -> typing.Optional[SearchField]:
318324
def field(self, sf: typing.Optional[SearchField]) -> None:
319325
"""Set search field property."""
320326
self._field = copy.deepcopy(sf) if sf else None
327+
if self._field and getattr(self, "_platform", None) == PLATFORM.GENERIC.value:
328+
self._field.value = self._field.value.lower()
321329

322330
def replace(self, new_query: Query) -> None:
323331
"""Replace this query with a new query in the parent's children list."""

0 commit comments

Comments
 (0)