From ab8b4f25eebfbd2ef5819ff98dd372d5392c4b6b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 8 Jun 2022 21:35:02 -0400 Subject: restore parameter escaping for public methods Adjusted the fix made for :ticket:`8056` which adjusted the escaping of bound parameter names with special characters such that the escaped names were translated after the SQL compilation step, which broke a published recipe on the FAQ illustrating how to merge parameter names into the string output of a compiled SQL string. The change restores the escaped names that come from ``compiled.params`` and adds a conditional parameter to :meth:`.SQLCompiler.construct_params` named ``escape_names`` that defaults to ``True``, restoring the old behavior by default. Fixes: #8113 Change-Id: I9cbedb1080bc06d51f287fd2cbf26aaab1c74653 --- lib/sqlalchemy/engine/default.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/engine') diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index 6b76601ff..df35e7128 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -943,13 +943,15 @@ class DefaultExecutionContext(ExecutionContext): if not parameters: self.compiled_parameters = [ compiled.construct_params( - extracted_parameters=extracted_parameters + extracted_parameters=extracted_parameters, + escape_names=False, ) ] else: self.compiled_parameters = [ compiled.construct_params( m, + escape_names=False, _group_number=grp, extracted_parameters=extracted_parameters, ) -- cgit v1.2.1