Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add default converter support for UUID type. #27

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions xmodel/converters.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import uuid

import ciso8601

from xmodel.base.fields import Converter, Field
Expand Down Expand Up @@ -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),
}
3 changes: 2 additions & 1 deletion xmodel/remote/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dataclasses
import uuid
from decimal import Decimal
from logging import getLogger
from typing import (
Expand Down Expand Up @@ -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

Expand Down