Skip to content

Commit 6446f7f

Browse files
committed
Add explicit value mappers for string types
1 parent 80893ff commit 6446f7f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

trino/mapper.py

+11
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ def map(self, value) -> Optional[Decimal]:
7474
return Decimal(value)
7575

7676

77+
class StringValueMapper(ValueMapper[str]):
78+
def map(self, value: Any) -> Optional[str]:
79+
if value is None:
80+
return None
81+
return str(value)
82+
83+
7784
class BinaryValueMapper(ValueMapper[bytes]):
7885
def map(self, value) -> Optional[bytes]:
7986
if value is None:
@@ -252,8 +259,12 @@ def _create_value_mapper(self, column) -> ValueMapper:
252259
return DoubleValueMapper()
253260
if col_type == 'decimal':
254261
return DecimalValueMapper()
262+
if col_type in {'varchar', 'char'}:
263+
return StringValueMapper()
255264
if col_type == 'varbinary':
256265
return BinaryValueMapper()
266+
if col_type == 'json':
267+
return StringValueMapper()
257268
if col_type == 'date':
258269
return DateValueMapper()
259270
if col_type == 'time':

0 commit comments

Comments
 (0)