Skip to content

Commit

Permalink
fix on Encoder for UUIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
phenobarbital committed Apr 5, 2022
1 parent be3fe1b commit 82d73e7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion asyncdb/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
import inspect
import traceback
import operator
import rapidjson as to_json
from dataclasses import Field as ff
from dataclasses import (
Expand All @@ -26,7 +27,8 @@
Dict,
Optional,
Union,
Any
Any,
Iterable
)
from asyncdb.utils import Msg
from asyncdb.utils.types import (
Expand Down
5 changes: 3 additions & 2 deletions asyncdb/utils/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ def default(self, obj):
return str(obj.value)
elif isinstance(obj, uuid.UUID):
try:
if uobj := uuid.UUID(obj, version=4):
return str(uobj)
except ValueError:
return str(obj)
except Exception as e:
return obj.hex
elif isinstance(obj, decimal.Decimal):
return float(obj)
elif isinstance(obj, Decimal):
Expand Down
2 changes: 1 addition & 1 deletion asyncdb/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__title__ = 'asyncdb'
__description__ = ('Library for Asynchronous data source connections '
'Collection of asyncio drivers.')
__version__ = '2.0.23'
__version__ = '2.0.24'
__author__ = 'Jesus Lara'
__author_email__ = 'jesuslarag@gmail.com'
__license__ = 'BSD'

0 comments on commit 82d73e7

Please sign in to comment.