Skip to content

Commit

Permalink
Add explicit value mappers for string types
Browse files Browse the repository at this point in the history
  • Loading branch information
hashhar committed Jan 24, 2024
1 parent 7dfcdfc commit ca38d29
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions trino/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit ca38d29

Please sign in to comment.