From e8034bc3e596a1ca6a4ceec147373335c4d6f673 Mon Sep 17 00:00:00 2001 From: Bryan Ho Date: Fri, 26 Jan 2024 10:37:48 -0800 Subject: [PATCH] reset to default --- src/sql/connection/connection.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/sql/connection/connection.py b/src/sql/connection/connection.py index 4e8e2de5a..0ece04719 100644 --- a/src/sql/connection/connection.py +++ b/src/sql/connection/connection.py @@ -758,8 +758,6 @@ def _connection_execute(self, query, parameters=None): def _execute_with_parameters(self, query, parameters): """Execute the query with the given parameters""" - if not parameters: - return self._connection.exec_driver_sql(query) if IS_SQLALCHEMY_ONE: out = self._connection.execute(sqlalchemy.text(query), **parameters) @@ -770,7 +768,7 @@ def _execute_with_parameters(self, query, parameters): return out - def raw_execute(self, query, parameters=None, with_=None): + def raw_execute(self, query, parameters=None, with_=None): # Reset to default """Run the query without any preprocessing Parameters @@ -793,20 +791,19 @@ def raw_execute(self, query, parameters=None, with_=None): if with_: query = self._resolve_cte(query, with_) - if parameters: - query, quoted_named_parameters = escape_string_literals_with_colon_prefix(query) - - if quoted_named_parameters: - intersection = set(quoted_named_parameters) & set(parameters) - - if intersection: - intersection_ = ", ".join(sorted(intersection)) - warnings.warn( - f"The following variables are defined: {intersection_}. However " - "the parameters are quoted in the query, if you want to use " - "them as named parameters, remove the quotes.", - category=JupySQLQuotedNamedParametersWarning, - ) + query, quoted_named_parameters = escape_string_literals_with_colon_prefix(query) + + if quoted_named_parameters and parameters: + intersection = set(quoted_named_parameters) & set(parameters) + + if intersection: + intersection_ = ", ".join(sorted(intersection)) + warnings.warn( + f"The following variables are defined: {intersection_}. However " + "the parameters are quoted in the query, if you want to use " + "them as named parameters, remove the quotes.", + category=JupySQLQuotedNamedParametersWarning, + ) if parameters: required_parameters = set(sqlalchemy.text(query).compile().params)