Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions uncoder-core/app/translator/core/custom_types/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ class OperatorType(CustomEnum):
class GroupType(CustomEnum):
L_PAREN = "("
R_PAREN = ")"


STR_SEARCH_OPERATORS = (
OperatorType.CONTAINS, OperatorType.NOT_CONTAINS, OperatorType.ENDSWITH, OperatorType.NOT_ENDSWITH,
OperatorType.STARTSWITH, OperatorType.NOT_STARTSWITH, OperatorType.REGEX, OperatorType.NOT_REGEX
)
7 changes: 5 additions & 2 deletions uncoder-core/app/translator/core/models/field.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional, Union

from app.translator.core.custom_types.tokens import OperatorType
from app.translator.core.custom_types.tokens import OperatorType, STR_SEARCH_OPERATORS
from app.translator.core.mapping import DEFAULT_MAPPING_NAME, SourceMapping
from app.translator.core.models.identifier import Identifier
from app.translator.core.str_value_manager import StrValue
Expand All @@ -14,6 +14,9 @@ def __init__(self, source_name: str):
def get_generic_field_name(self, source_id: str) -> Optional[str]:
return self.__generic_names_map.get(source_id)

def add_generic_names_map(self, generic_names_map: dict) -> None:
self.__generic_names_map = generic_names_map

def set_generic_names_map(self, source_mappings: list[SourceMapping], default_mapping: SourceMapping) -> None:
generic_names_map = {
source_mapping.source_id: source_mapping.fields_mapping.get_generic_field_name(self.source_name)
Expand Down Expand Up @@ -46,7 +49,7 @@ def __add_value(self, value: Optional[Union[int, str, StrValue, list, tuple]]) -
if value and isinstance(value, (list, tuple)):
for v in value:
self.__add_value(v)
elif value and isinstance(value, str) and value.isnumeric():
elif value and isinstance(value, str) and value.isnumeric() and self.operator.token_type not in STR_SEARCH_OPERATORS:
self.values.append(int(value))
elif value is not None and isinstance(value, (int, str)):
self.values.append(value)
Expand Down