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

Fix version comparison in UUID type #643

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 3 additions & 2 deletions sqlalchemy_utils/types/uuid.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import uuid

from packaging.version import Version
from sqlalchemy import __version__, types, util
from sqlalchemy.dialects import mssql, postgresql

from .scalar_coercible import ScalarCoercible

sqlalchemy_version = tuple([int(v) for v in __version__.split(".")])
sqlalchemy_version = Version(__version__)


class UUIDType(ScalarCoercible, types.TypeDecorator):
Expand Down Expand Up @@ -71,7 +72,7 @@ def _coerce(value):

# sqlalchemy >= 1.4.30 quotes UUID's automatically.
# It is only necessary to quote UUID's in sqlalchemy < 1.4.30.
if sqlalchemy_version < (1, 4, 30):
if sqlalchemy_version < Version("1.4.30"):
def process_literal_param(self, value, dialect):
return "'{}'".format(value) if value else value
else:
Expand Down