diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-03-09 13:36:34 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-03-09 13:36:34 -0500 |
commit | 79bde753e47bd86f0199c4aa6a5c2ead1e4aec95 (patch) | |
tree | e93e70057e6123d6871f3481d7a6c53c453149f5 /lib/sqlalchemy/sql/compiler.py | |
parent | 85c843bcc3ea1ca16be06fe85b03d99c4e519f3d (diff) | |
download | sqlalchemy-79bde753e47bd86f0199c4aa6a5c2ead1e4aec95.tar.gz |
Apply percent sign escaping to op(), custom_op()
Fixed bug where the "percent escaping" feature that occurs with dialects
that use the "format" or "pyformat" bound parameter styles was not enabled
for the :meth:`.Operations.op` and :meth:`.Operations.custom_op` methods,
for custom operators that use percent signs. The percent sign will now be
automatically doubled based on the paramstyle as necessary.
Fixes: #6016
Change-Id: I285c5fc082481c2ee989edf1b02a83a6087ea26a
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 8f046a802..0ea251fb4 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -2055,17 +2055,19 @@ class SQLCompiler(Compiled): def visit_custom_op_binary(self, element, operator, **kw): kw["eager_grouping"] = operator.eager_grouping return self._generate_generic_binary( - element, " " + operator.opstring + " ", **kw + element, + " " + self.escape_literal_column(operator.opstring) + " ", + **kw ) def visit_custom_op_unary_operator(self, element, operator, **kw): return self._generate_generic_unary_operator( - element, operator.opstring + " ", **kw + element, self.escape_literal_column(operator.opstring) + " ", **kw ) def visit_custom_op_unary_modifier(self, element, operator, **kw): return self._generate_generic_unary_modifier( - element, " " + operator.opstring, **kw + element, " " + self.escape_literal_column(operator.opstring), **kw ) def _generate_generic_binary( |