From c0e61af2c89e82a2cd1d9fe43c223e4e1d43aa28 Mon Sep 17 00:00:00 2001 From: Josh Orr Date: Wed, 8 Nov 2023 15:50:00 -0700 Subject: [PATCH] feat: add default converter support for UUID type. --- xmodel/converters.py | 3 +++ xmodel/remote/api.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/xmodel/converters.py b/xmodel/converters.py index 4660e86..40b8e31 100644 --- a/xmodel/converters.py +++ b/xmodel/converters.py @@ -1,3 +1,5 @@ +import uuid + import ciso8601 from xmodel.base.fields import Converter, Field @@ -255,4 +257,5 @@ def convert_decimal( float: ConvertBasicType(basic_type=float), str: ConvertBasicType(basic_type=str), bool: ConvertBasicBool(), + uuid.UUID: ConvertBasicType(basic_type=str), } diff --git a/xmodel/remote/api.py b/xmodel/remote/api.py index 8df4169..cbc2e2c 100644 --- a/xmodel/remote/api.py +++ b/xmodel/remote/api.py @@ -1,4 +1,5 @@ import dataclasses +import uuid from decimal import Decimal from logging import getLogger from typing import ( @@ -242,7 +243,7 @@ def get_via_id( value_type = type(id) # Treat a Decimal as a string for the purposes of querying for it. - if type(id) is Decimal: + if type(id) in (Decimal, uuid.UUID): id = str(id) value_type = str