diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-05-25 08:47:29 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-05-25 10:07:31 -0400 |
commit | a5d481eaa5bff958692fc3b0024f0b9b1c4f56c6 (patch) | |
tree | e1a53b2d9ee12ac5d49c14eb85483c0a118745c7 /lib/sqlalchemy/sql/compiler.py | |
parent | d7b131d2dfc4c519b23d9ed29364036ef88b1863 (diff) | |
download | sqlalchemy-a5d481eaa5bff958692fc3b0024f0b9b1c4f56c6.tar.gz |
apply bindparam escape name to processors dictionary
Fixed SQL compiler issue where the "bind processing" function for a bound
parameter would not be correctly applied to a bound value if the bound
parameter's name were "escaped". Concretely, this applies, among other
cases, to Oracle when a :class:`.Column` has a name that itself requires
quoting, such that the quoting-required name is then used for the bound
parameters generated within DML statements, and the datatype in use
requires bind processing, such as the :class:`.Enum` datatype.
Fixes: #8053
Change-Id: I39d060a87e240b4ebcfccaa9c535e971b7255d99
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 0eae31a1a..63ed45a96 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -1143,10 +1143,18 @@ class SQLCompiler(Compiled): str, Union[_BindProcessorType[Any], Sequence[_BindProcessorType[Any]]] ]: + _escaped_bind_names = self.escaped_bind_names + has_escaped_names = bool(_escaped_bind_names) + # mypy is not able to see the two value types as the above Union, # it just sees "object". don't know how to resolve return dict( - (key, value) # type: ignore + ( + _escaped_bind_names.get(key, key) + if has_escaped_names + else key, + value, + ) # type: ignore for key, value in ( ( self.bind_names[bindparam], |