|
23 | 23 | from app.translator.const import DEFAULT_VALUE_TYPE
|
24 | 24 | from app.translator.core.custom_types.meta_info import SeverityType
|
25 | 25 | from app.translator.core.custom_types.tokens import OperatorType
|
| 26 | +from app.translator.core.custom_types.values import ValueType |
26 | 27 | from app.translator.core.mapping import DEFAULT_MAPPING_NAME, SourceMapping
|
27 | 28 | from app.translator.core.models.query_tokens.field_value import FieldValue
|
28 | 29 | from app.translator.core.models.query_tokens.keyword import Keyword
|
@@ -211,18 +212,26 @@ def generate_field(self, data: FieldValue, source_mapping: SourceMapping):
|
211 | 212 | ):
|
212 | 213 | field_name = f"{field_name}|{data.operator.token_type}"
|
213 | 214 |
|
214 |
| - values = self.__pre_process_values(data.values) |
| 215 | + value_type_map = { |
| 216 | + OperatorType.REGEX: ValueType.regex_value |
| 217 | + } |
| 218 | + value_type = value_type_map.get(data.operator.token_type, ValueType.value) |
| 219 | + values = self.__pre_process_values(data.values, value_type) |
215 | 220 | if len(values) == 1:
|
216 | 221 | return {field_name: values[0]}
|
217 | 222 | elif len(values) == 0:
|
218 | 223 | return {field_name: ""}
|
219 | 224 | return {field_name: values}
|
220 | 225 |
|
221 |
| - def __pre_process_values(self, values: DEFAULT_VALUE_TYPE) -> list[Union[int, str]]: |
| 226 | + def __pre_process_values( |
| 227 | + self, |
| 228 | + values: DEFAULT_VALUE_TYPE, |
| 229 | + value_type: str = ValueType.value |
| 230 | + ) -> list[Union[int, str]]: |
222 | 231 | processed = []
|
223 | 232 | for v in values:
|
224 | 233 | if isinstance(v, StrValue):
|
225 |
| - processed.append(self.str_value_manager.from_container_to_str(v)) |
| 234 | + processed.append(self.str_value_manager.from_container_to_str(v, value_type=value_type)) |
226 | 235 | elif isinstance(v, str):
|
227 | 236 | processed.append(v)
|
228 | 237 | else:
|
|
0 commit comments