Skip to content

Commit 887c6b2

Browse files
authored
Add Python version check for UUID6 and UUID7 support
Signed-off-by: lajxw <46254113+lajxw@users.noreply.github.com>
1 parent 6bc9e1d commit 887c6b2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

advanced_alchemy/mixins/uuid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class UUIDv6PrimaryKey(SentinelMixin):
4141

4242
def __init_subclass__(cls, **kwargs: Any) -> None:
4343
super().__init_subclass__(**kwargs)
44-
if not UUID_UTILS_INSTALLED and not cls.__module__.startswith("advanced_alchemy"): # pragma: no cover
44+
if not _PYTHON_SUPPORTS_UUID6_7 and not UUID_UTILS_INSTALLED and not cls.__module__.startswith("advanced_alchemy"): # pragma: no cover
4545
logger.warning("`uuid-utils` not installed, falling back to `uuid4` for UUID v6 generation.")
4646

4747
id: Mapped[UUID] = mapped_column(default=uuid6, primary_key=True, sort_order=-100)
@@ -54,7 +54,7 @@ class UUIDv7PrimaryKey(SentinelMixin):
5454

5555
def __init_subclass__(cls, **kwargs: Any) -> None:
5656
super().__init_subclass__(**kwargs)
57-
if not UUID_UTILS_INSTALLED and not cls.__module__.startswith("advanced_alchemy"): # pragma: no cover
57+
if not _PYTHON_SUPPORTS_UUID6_7 and not UUID_UTILS_INSTALLED and not cls.__module__.startswith("advanced_alchemy"): # pragma: no cover
5858
logger.warning("`uuid-utils` not installed, falling back to `uuid4` for UUID v7 generation.")
5959

6060
id: Mapped[UUID] = mapped_column(default=uuid7, primary_key=True, sort_order=-100)

0 commit comments

Comments
 (0)