Skip to content

Commit 0a7cb06

Browse files
committed
Int value with Contains operator
1 parent e713136 commit 0a7cb06

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

uncoder-core/app/translator/core/custom_types/tokens.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@ class OperatorType(CustomEnum):
3030
class GroupType(CustomEnum):
3131
L_PAREN = "("
3232
R_PAREN = ")"
33+
34+
35+
STR_SEARCH_OPERATORS = (
36+
OperatorType.CONTAINS, OperatorType.NOT_CONTAINS, OperatorType.ENDSWITH, OperatorType.NOT_ENDSWITH,
37+
OperatorType.STARTSWITH, OperatorType.NOT_STARTSWITH, OperatorType.REGEX, OperatorType.NOT_REGEX
38+
)

uncoder-core/app/translator/core/models/field.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional, Union
22

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

17+
def add_generic_names_map(self, generic_names_map: dict) -> None:
18+
self.__generic_names_map = generic_names_map
19+
1720
def set_generic_names_map(self, source_mappings: list[SourceMapping], default_mapping: SourceMapping) -> None:
1821
generic_names_map = {
1922
source_mapping.source_id: source_mapping.fields_mapping.get_generic_field_name(self.source_name)
@@ -46,7 +49,7 @@ def __add_value(self, value: Optional[Union[int, str, StrValue, list, tuple]]) -
4649
if value and isinstance(value, (list, tuple)):
4750
for v in value:
4851
self.__add_value(v)
49-
elif value and isinstance(value, str) and value.isnumeric():
52+
elif value and isinstance(value, str) and value.isnumeric() and self.operator.token_type not in STR_SEARCH_OPERATORS:
5053
self.values.append(int(value))
5154
elif value is not None and isinstance(value, (int, str)):
5255
self.values.append(value)

0 commit comments

Comments
 (0)