From 686fc9523e0122b155134f61072ff68c4f9b7b09 Mon Sep 17 00:00:00 2001 From: hendelbah <77179007+hendelbah@users.noreply.github.com> Date: Thu, 1 Aug 2024 12:28:18 +0300 Subject: [PATCH] Fix Mysql `UUIDField` with `binary_compression=True` (#1687) * fix mysql UUIDField * Update fields.py --- tortoise/contrib/mysql/fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tortoise/contrib/mysql/fields.py b/tortoise/contrib/mysql/fields.py index 1f5d73235..5d593e1e6 100644 --- a/tortoise/contrib/mysql/fields.py +++ b/tortoise/contrib/mysql/fields.py @@ -49,7 +49,7 @@ def to_db_value(self, value: Any, instance: "Union[Type[Model], Model]") -> Opti # If not, raise an error # This is to prevent UUIDv1 or any other version from being stored in the database if self._binary_compression: - if value is not isinstance(value, UUID): + if not isinstance(value, UUID): raise ValueError("UUIDField only accepts UUID values") return value.bytes return value and str(value)