From ca38d2908533d891eedf5ee80f38dbdcfbbdb564 Mon Sep 17 00:00:00 2001 From: Ashhar Hasan Date: Mon, 22 Jan 2024 23:08:52 +0530 Subject: [PATCH] Add explicit value mappers for string types --- trino/mapper.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/trino/mapper.py b/trino/mapper.py index 945d2f77..f29dd666 100644 --- a/trino/mapper.py +++ b/trino/mapper.py @@ -74,6 +74,13 @@ def map(self, value) -> Optional[Decimal]: return Decimal(value) +class StringValueMapper(ValueMapper[str]): + def map(self, value: Any) -> Optional[str]: + if value is None: + return None + return str(value) + + class BinaryValueMapper(ValueMapper[bytes]): def map(self, value) -> Optional[bytes]: if value is None: @@ -252,8 +259,12 @@ def _create_value_mapper(self, column) -> ValueMapper: return DoubleValueMapper() if col_type == 'decimal': return DecimalValueMapper() + if col_type in {'varchar', 'char'}: + return StringValueMapper() if col_type == 'varbinary': return BinaryValueMapper() + if col_type == 'json': + return StringValueMapper() if col_type == 'date': return DateValueMapper() if col_type == 'time':