summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
authorJosé Duarte <duarte@dystematic.com>2022-01-13 17:20:06 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-01-14 16:42:16 -0500
commit17d228f6268515bbf37fdd70a6ee3a62cb9a0b0c (patch)
tree061124afad16e8198f0c133a9ec7929038a8433c /lib/sqlalchemy/dialects/postgresql/base.py
parenta869dc8fe3cd579ed9bab665d215a6c3e3d8a4ca (diff)
downloadsqlalchemy-17d228f6268515bbf37fdd70a6ee3a62cb9a0b0c.tar.gz
Fixes(#7561) Add support for postgres.UUID literal_binds compilation
Added string rendering to the :class:`.postgresql.UUID` datatype, so that stringifying a statement with "literal_binds" that uses this type will render an appropriate string value for the PostgreSQL backend. Pull request courtesy José Duarte. Fixes: #7561 Closes: #7563 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7563 Pull-request-sha: cf6fe73265342d7884a940c4b3a34c9552113ec3 Change-Id: I4b162bdcdce2293a90683e36da54e4a891a3c684
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index bf8812ae5..4f3e297ef 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -1410,7 +1410,6 @@ from ...types import SMALLINT
from ...types import TEXT
from ...types import VARCHAR
-
IDX_USING = re.compile(r"^(?:btree|hash|gist|gin|[\w_]+)$", re.I)
RESERVED_WORDS = set(
@@ -1751,6 +1750,24 @@ class UUID(sqltypes.TypeEngine):
else:
return None
+ def literal_processor(self, dialect):
+ if self.as_uuid:
+
+ def process(value):
+ if value is not None:
+ value = "'%s'::UUID" % value
+ return value
+
+ return process
+ else:
+
+ def process(value):
+ if value is not None:
+ value = "'%s'" % value
+ return value
+
+ return process
+
PGUuid = UUID