diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2021-10-15 15:27:45 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2021-10-15 15:27:45 +0000 |
commit | 165bc7529d858a8cd6c7daa409d091f7c728c20f (patch) | |
tree | 5de49faa9d240ccbe43c0a872949cb541b72cd34 /lib/sqlalchemy/dialects/postgresql/base.py | |
parent | 73b69903d2fb9fd20c7b5cdd3fbde2df26f96c2a (diff) | |
parent | 639cf972f15c8fbf77980b04fff8e5dbc82af7b6 (diff) | |
download | sqlalchemy-165bc7529d858a8cd6c7daa409d091f7c728c20f.tar.gz |
Merge "support bind expressions w/ expanding IN; apply to psycopg2" into main
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 2e28b45ca..c1a2cf81d 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -2047,6 +2047,15 @@ class ENUM(sqltypes.NativeForEmulated, sqltypes.Enum): self.drop(bind=bind, checkfirst=checkfirst) +class _ColonCast(elements.Cast): + __visit_name__ = "colon_cast" + + def __init__(self, expression, type_): + self.type = type_ + self.clause = expression + self.typeclause = elements.TypeClause(type_) + + colspecs = { sqltypes.ARRAY: _array.ARRAY, sqltypes.Interval: INTERVAL, @@ -2102,6 +2111,12 @@ ischema_names = { class PGCompiler(compiler.SQLCompiler): + def visit_colon_cast(self, element, **kw): + return "%s::%s" % ( + element.clause._compiler_dispatch(self, **kw), + element.typeclause._compiler_dispatch(self, **kw), + ) + def visit_array(self, element, **kw): return "ARRAY[%s]" % self.visit_clauselist(element, **kw) |