From cce29df497db2d0674c6f2e128431e52a26b01b7 Mon Sep 17 00:00:00 2001 From: Pavlo Mishchenko Date: Tue, 20 Jan 2026 16:05:53 +0200 Subject: [PATCH 1/7] Apply string interpolation in mogrify regardless of args presence --- singlestoredb/mysql/cursors.py | 2 ++ singlestoredb/tests/test.sql | 5 +++++ singlestoredb/tests/test_connection.py | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/singlestoredb/mysql/cursors.py b/singlestoredb/mysql/cursors.py index f77ebbf83..7bf4cfdb5 100644 --- a/singlestoredb/mysql/cursors.py +++ b/singlestoredb/mysql/cursors.py @@ -183,6 +183,8 @@ def mogrify(self, query, args=None): if args: query = query % self._escape_args(args, conn) + else: + query = query % () return query diff --git a/singlestoredb/tests/test.sql b/singlestoredb/tests/test.sql index 25efc3f02..66564b8b8 100644 --- a/singlestoredb/tests/test.sql +++ b/singlestoredb/tests/test.sql @@ -708,5 +708,10 @@ INSERT INTO bool_data_with_nulls SET id='nt', bool_a=NULL, bool_b=TRUE; INSERT INTO bool_data_with_nulls SET id='nn', bool_a=NULL, bool_b=NULL; INSERT INTO bool_data_with_nulls SET id='ff', bool_a=FALSE, bool_b=FALSE; +CREATE TABLE IF NOT EXISTS test_val_with_percent ( + i VARCHAR(16) +); +-- Double percent sign for execution from python +INSERT INTO test_val_with_percent VALUES ('a%%a'); COMMIT; diff --git a/singlestoredb/tests/test_connection.py b/singlestoredb/tests/test_connection.py index 7158ca7d7..9de1ec45b 100755 --- a/singlestoredb/tests/test_connection.py +++ b/singlestoredb/tests/test_connection.py @@ -3144,6 +3144,24 @@ def test_f16_vectors(self): decimal=2, ) + def test_mogrify_val_with_percent(self): + val_with_percent = 'a%a' + self.cur.execute( + '''SELECT REPLACE(i, "%%", "\\%%") + FROM test_val_with_percent''', + ) + res1 = self.cur.fetchall() + assert res1[0][0] == 'a\\%a' + + self.cur.execute( + '''SELECT REPLACE(i, "%%", "\\%%") + FROM test_val_with_percent + WHERE i = %s''', + (val_with_percent,), + ) + res2 = self.cur.fetchall() + assert res2[0][0] == 'a\\%a' + if __name__ == '__main__': import nose2 From 8573373a2e1a14e74308532a3ca52d746e2c1dae Mon Sep 17 00:00:00 2001 From: Pavlo Mishchenko Date: Tue, 20 Jan 2026 16:42:25 +0200 Subject: [PATCH 2/7] Fix command with one % --- singlestoredb/tests/test_fusion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singlestoredb/tests/test_fusion.py b/singlestoredb/tests/test_fusion.py index 9f25f0cfa..42b0a0d90 100644 --- a/singlestoredb/tests/test_fusion.py +++ b/singlestoredb/tests/test_fusion.py @@ -79,7 +79,7 @@ def test_show_commands(self): assert cmds assert [x for x in cmds if x.strip().startswith('SHOW FUSION GRAMMAR')], cmds - self.cur.execute('show fusion commands like "create%"') + self.cur.execute('show fusion commands like "create%%"') cmds = [x[0] for x in self.cur.fetchall()] assert cmds assert [x for x in cmds if x.strip().startswith('CREATE')] == cmds, cmds From 1d2a2e8557a914028e998eb8155b1ae7a9b5bf11 Mon Sep 17 00:00:00 2001 From: Pavlo Mishchenko Date: Tue, 20 Jan 2026 17:47:03 +0200 Subject: [PATCH 3/7] Same fix for http --- singlestoredb/connection.py | 40 ++++++++++++++++++------------------ singlestoredb/tests/utils.py | 3 ++- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/singlestoredb/connection.py b/singlestoredb/connection.py index 425def6f2..e9f9f726d 100644 --- a/singlestoredb/connection.py +++ b/singlestoredb/connection.py @@ -1120,32 +1120,32 @@ def _convert_params( params: Optional[Union[Sequence[Any], Dict[str, Any], Any]], ) -> Tuple[Any, ...]: """Convert query to correct parameter format.""" - if params: - if cls._map_param_converter is None: - cls._map_param_converter = sqlparams.SQLParams( - map_paramstyle, cls.paramstyle, escape_char=True, - ) - - if cls._positional_param_converter is None: - cls._positional_param_converter = sqlparams.SQLParams( - positional_paramstyle, cls.paramstyle, escape_char=True, - ) + if cls._map_param_converter is None: + cls._map_param_converter = sqlparams.SQLParams( + map_paramstyle, cls.paramstyle, escape_char=True, + ) - is_sequence = isinstance(params, Sequence) \ - and not isinstance(params, str) \ - and not isinstance(params, bytes) - is_mapping = isinstance(params, Mapping) + if cls._positional_param_converter is None: + cls._positional_param_converter = sqlparams.SQLParams( + positional_paramstyle, cls.paramstyle, escape_char=True, + ) - param_converter = cls._map_param_converter \ - if is_mapping else cls._positional_param_converter + is_sequence = isinstance(params, Sequence) \ + and not isinstance(params, str) \ + and not isinstance(params, bytes) + is_mapping = isinstance(params, Mapping) - if not is_sequence and not is_mapping: - params = [params] + param_converter = cls._map_param_converter \ + if is_mapping else cls._positional_param_converter - return param_converter.format(oper, params) + params_to_use = params + if not params: + params_to_use = () + elif not is_sequence and not is_mapping: + params_to_use = [params] - return (oper, None) + return param_converter.format(oper, params_to_use) def autocommit(self, value: bool = True) -> None: """Set autocommit mode.""" diff --git a/singlestoredb/tests/utils.py b/singlestoredb/tests/utils.py index c7cba6808..c4db99f1b 100644 --- a/singlestoredb/tests/utils.py +++ b/singlestoredb/tests/utils.py @@ -220,7 +220,8 @@ def load_sql(sql_file: str) -> str: cur.execute(f'USE {dbname};') # Start HTTP server as needed. - if http_port and not conn.driver.startswith('http'): + if http_port and not conn.driver.startswith('http') and \ + 'IS_HELIOS' not in os.environ: cur.execute(f'SET GLOBAL HTTP_PROXY_PORT={http_port};') cur.execute('SET GLOBAL HTTP_API=ON;') cur.execute('RESTART PROXY;') From 327948d0d4d4d341c091f4d3a896feda85cdfd03 Mon Sep 17 00:00:00 2001 From: Pavlo Mishchenko Date: Thu, 22 Jan 2026 17:59:02 +0200 Subject: [PATCH 4/7] Back to consistent behavior --- singlestoredb/connection.py | 40 +++++++++++++------------- singlestoredb/mysql/cursors.py | 4 +-- singlestoredb/tests/test_connection.py | 1 + singlestoredb/tests/test_fusion.py | 2 +- singlestoredb/tests/utils.py | 3 +- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/singlestoredb/connection.py b/singlestoredb/connection.py index e9f9f726d..989380074 100644 --- a/singlestoredb/connection.py +++ b/singlestoredb/connection.py @@ -1120,32 +1120,32 @@ def _convert_params( params: Optional[Union[Sequence[Any], Dict[str, Any], Any]], ) -> Tuple[Any, ...]: """Convert query to correct parameter format.""" + if params is not None: - if cls._map_param_converter is None: - cls._map_param_converter = sqlparams.SQLParams( - map_paramstyle, cls.paramstyle, escape_char=True, - ) + if cls._map_param_converter is None: + cls._map_param_converter = sqlparams.SQLParams( + map_paramstyle, cls.paramstyle, escape_char=True, + ) - if cls._positional_param_converter is None: - cls._positional_param_converter = sqlparams.SQLParams( - positional_paramstyle, cls.paramstyle, escape_char=True, - ) + if cls._positional_param_converter is None: + cls._positional_param_converter = sqlparams.SQLParams( + positional_paramstyle, cls.paramstyle, escape_char=True, + ) - is_sequence = isinstance(params, Sequence) \ - and not isinstance(params, str) \ - and not isinstance(params, bytes) - is_mapping = isinstance(params, Mapping) + is_sequence = isinstance(params, Sequence) \ + and not isinstance(params, str) \ + and not isinstance(params, bytes) + is_mapping = isinstance(params, Mapping) - param_converter = cls._map_param_converter \ - if is_mapping else cls._positional_param_converter + param_converter = cls._map_param_converter \ + if is_mapping else cls._positional_param_converter - params_to_use = params - if not params: - params_to_use = () - elif not is_sequence and not is_mapping: - params_to_use = [params] + if not is_sequence and not is_mapping: + params = [params] + + return param_converter.format(oper, params) - return param_converter.format(oper, params_to_use) + return (oper, None) def autocommit(self, value: bool = True) -> None: """Set autocommit mode.""" diff --git a/singlestoredb/mysql/cursors.py b/singlestoredb/mysql/cursors.py index 7bf4cfdb5..640cfe7a3 100644 --- a/singlestoredb/mysql/cursors.py +++ b/singlestoredb/mysql/cursors.py @@ -181,10 +181,8 @@ def mogrify(self, query, args=None): """ conn = self._get_db() - if args: + if args is not None: query = query % self._escape_args(args, conn) - else: - query = query % () return query diff --git a/singlestoredb/tests/test_connection.py b/singlestoredb/tests/test_connection.py index 9de1ec45b..7d2da9469 100755 --- a/singlestoredb/tests/test_connection.py +++ b/singlestoredb/tests/test_connection.py @@ -3149,6 +3149,7 @@ def test_mogrify_val_with_percent(self): self.cur.execute( '''SELECT REPLACE(i, "%%", "\\%%") FROM test_val_with_percent''', + (), ) res1 = self.cur.fetchall() assert res1[0][0] == 'a\\%a' diff --git a/singlestoredb/tests/test_fusion.py b/singlestoredb/tests/test_fusion.py index 42b0a0d90..9f25f0cfa 100644 --- a/singlestoredb/tests/test_fusion.py +++ b/singlestoredb/tests/test_fusion.py @@ -79,7 +79,7 @@ def test_show_commands(self): assert cmds assert [x for x in cmds if x.strip().startswith('SHOW FUSION GRAMMAR')], cmds - self.cur.execute('show fusion commands like "create%%"') + self.cur.execute('show fusion commands like "create%"') cmds = [x[0] for x in self.cur.fetchall()] assert cmds assert [x for x in cmds if x.strip().startswith('CREATE')] == cmds, cmds diff --git a/singlestoredb/tests/utils.py b/singlestoredb/tests/utils.py index c4db99f1b..c7cba6808 100644 --- a/singlestoredb/tests/utils.py +++ b/singlestoredb/tests/utils.py @@ -220,8 +220,7 @@ def load_sql(sql_file: str) -> str: cur.execute(f'USE {dbname};') # Start HTTP server as needed. - if http_port and not conn.driver.startswith('http') and \ - 'IS_HELIOS' not in os.environ: + if http_port and not conn.driver.startswith('http'): cur.execute(f'SET GLOBAL HTTP_PROXY_PORT={http_port};') cur.execute('SET GLOBAL HTTP_API=ON;') cur.execute('RESTART PROXY;') From 374a4bc38e0cd863e0aca4c7a4638adb084e478a Mon Sep 17 00:00:00 2001 From: Pavlo Mishchenko Date: Thu, 22 Jan 2026 18:07:54 +0200 Subject: [PATCH 5/7] Fix test data --- singlestoredb/tests/test.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singlestoredb/tests/test.sql b/singlestoredb/tests/test.sql index 66564b8b8..84484e442 100644 --- a/singlestoredb/tests/test.sql +++ b/singlestoredb/tests/test.sql @@ -712,6 +712,6 @@ CREATE TABLE IF NOT EXISTS test_val_with_percent ( i VARCHAR(16) ); -- Double percent sign for execution from python -INSERT INTO test_val_with_percent VALUES ('a%%a'); +INSERT INTO test_val_with_percent VALUES ('a%a'); COMMIT; From 5455c5ef14120d0ac60237658d7fdba607d3d4f9 Mon Sep 17 00:00:00 2001 From: Pavlo Mishchenko Date: Sat, 24 Jan 2026 18:11:55 +0200 Subject: [PATCH 6/7] mogrify empty args under options --- singlestoredb/config.py | 6 ++++++ singlestoredb/connection.py | 12 +++++++++++- singlestoredb/http/connection.py | 5 ++++- singlestoredb/mysql/connection.py | 2 ++ singlestoredb/mysql/cursors.py | 7 ++++++- singlestoredb/tests/test_connection.py | 10 ++++++---- singlestoredb/utils/mogrify.py | 11 ++++++++++- 7 files changed, 45 insertions(+), 8 deletions(-) diff --git a/singlestoredb/config.py b/singlestoredb/config.py index 71c751738..109cb6d61 100644 --- a/singlestoredb/config.py +++ b/singlestoredb/config.py @@ -251,6 +251,12 @@ environ='SINGLESTOREDB_VECTOR_DATA_FORMAT', ) +register_option( + 'mogrify_empty_args', 'bool', check_bool, False, + 'Should mogrify apply string interpolation when args is an empty tuple/list? ', + environ='SINGLESTOREDB_MOGRIFY_EMPTY_ARGS', +) + register_option( 'fusion.enabled', 'bool', check_bool, False, 'Should Fusion SQL queries be enabled?', diff --git a/singlestoredb/connection.py b/singlestoredb/connection.py index 989380074..848d42c1e 100644 --- a/singlestoredb/connection.py +++ b/singlestoredb/connection.py @@ -1118,9 +1118,15 @@ def __init__(self, **kwargs: Any): def _convert_params( cls, oper: str, params: Optional[Union[Sequence[Any], Dict[str, Any], Any]], + mogrify_empty_args: bool = False, ) -> Tuple[Any, ...]: """Convert query to correct parameter format.""" - if params is not None: + if mogrify_empty_args: + should_convert = params is not None + else: + should_convert = bool(params) + + if should_convert: if cls._map_param_converter is None: cls._map_param_converter = sqlparams.SQLParams( @@ -1333,6 +1339,7 @@ def connect( enable_extended_data_types: Optional[bool] = None, vector_data_format: Optional[str] = None, parse_json: Optional[bool] = None, + mogrify_empty_args: Optional[bool] = None, ) -> Connection: """ Return a SingleStoreDB connection. @@ -1418,6 +1425,9 @@ def connect( Should extended data types (BSON, vector) be enabled? vector_data_format : str, optional Format for vector types: json or binary + mogrify_empty_args : bool, optional + Should the connector apply parameter interpolation even when the + parameters are empty? This corresponds to pymysql/mysqlclient's handling Examples -------- diff --git a/singlestoredb/http/connection.py b/singlestoredb/http/connection.py index 28f48e8bf..dec48304f 100644 --- a/singlestoredb/http/connection.py +++ b/singlestoredb/http/connection.py @@ -548,7 +548,10 @@ def _execute( if handler is not None: return self._execute_fusion_query(oper, params, handler=handler) - oper, params = self._connection._convert_params(oper, params) + mogrify_empty_args = self._connection.connection_params.get( + 'mogrify_empty_args', False, + ) + oper, params = self._connection._convert_params(oper, params, mogrify_empty_args) log_query(oper, params) diff --git a/singlestoredb/mysql/connection.py b/singlestoredb/mysql/connection.py index 4ff6f37bb..938c368b8 100644 --- a/singlestoredb/mysql/connection.py +++ b/singlestoredb/mysql/connection.py @@ -360,6 +360,7 @@ def __init__( # noqa: C901 track_env=False, enable_extended_data_types=True, vector_data_format='binary', + mogrify_empty_args=None, ): BaseConnection.__init__(**dict(locals())) @@ -614,6 +615,7 @@ def _config(key, arg): self._auth_plugin_map = auth_plugin_map or {} self._binary_prefix = binary_prefix self.server_public_key = server_public_key + self.mogrify_empty_args = mogrify_empty_args if self.connection_params['nan_as_null'] or \ self.connection_params['inf_as_null']: diff --git a/singlestoredb/mysql/cursors.py b/singlestoredb/mysql/cursors.py index 640cfe7a3..0a387afdf 100644 --- a/singlestoredb/mysql/cursors.py +++ b/singlestoredb/mysql/cursors.py @@ -181,7 +181,12 @@ def mogrify(self, query, args=None): """ conn = self._get_db() - if args is not None: + if conn.mogrify_empty_args: + should_interpolate = args is not None + else: + should_interpolate = bool(args) + + if should_interpolate: query = query % self._escape_args(args, conn) return query diff --git a/singlestoredb/tests/test_connection.py b/singlestoredb/tests/test_connection.py index 7d2da9469..ba9a88d4b 100755 --- a/singlestoredb/tests/test_connection.py +++ b/singlestoredb/tests/test_connection.py @@ -3145,22 +3145,24 @@ def test_f16_vectors(self): ) def test_mogrify_val_with_percent(self): + conn = s2.connect(database=type(self).dbname, mogrify_empty_args=True) + cur = conn.cursor() val_with_percent = 'a%a' - self.cur.execute( + cur.execute( '''SELECT REPLACE(i, "%%", "\\%%") FROM test_val_with_percent''', (), ) - res1 = self.cur.fetchall() + res1 = cur.fetchall() assert res1[0][0] == 'a\\%a' - self.cur.execute( + cur.execute( '''SELECT REPLACE(i, "%%", "\\%%") FROM test_val_with_percent WHERE i = %s''', (val_with_percent,), ) - res2 = self.cur.fetchall() + res2 = cur.fetchall() assert res2[0][0] == 'a\\%a' diff --git a/singlestoredb/utils/mogrify.py b/singlestoredb/utils/mogrify.py index 2785e46ab..72b2b5994 100644 --- a/singlestoredb/utils/mogrify.py +++ b/singlestoredb/utils/mogrify.py @@ -123,6 +123,7 @@ def mogrify( encoders: Optional[Encoders] = None, server_status: int = 0, binary_prefix: bool = False, + mogrify_empty_args: bool = False, ) -> Union[str, bytes]: """ Returns the exact string sent to the database by calling the execute() method. @@ -135,13 +136,21 @@ def mogrify( Query to mogrify. args : Sequence[Any] or Dict[str, Any] or Any, optional Parameters used with query. (optional) + mogrify_empty_args : bool, optional + If True, apply string interpolation even when args is an empty tuple/list. + If False, only apply when args is truthy. Defaults to False. Returns ------- str : The query with argument binding applied. """ - if args: + if mogrify_empty_args: + should_interpolate = args is not None + else: + should_interpolate = bool(args) + + if should_interpolate: query = query % _escape_args( args, charset=charset, encoders=encoders, From cb6f3ac3cf1f82008c7970f5117c42e4b9034b08 Mon Sep 17 00:00:00 2001 From: Pavlo Mishchenko Date: Mon, 26 Jan 2026 12:11:54 +0200 Subject: [PATCH 7/7] Rename option --- singlestoredb/config.py | 4 ++-- singlestoredb/connection.py | 8 ++++---- singlestoredb/http/connection.py | 8 +++++--- singlestoredb/mysql/connection.py | 4 ++-- singlestoredb/mysql/cursors.py | 2 +- singlestoredb/tests/test_connection.py | 5 ++++- singlestoredb/utils/mogrify.py | 6 +++--- 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/singlestoredb/config.py b/singlestoredb/config.py index 109cb6d61..3154feb39 100644 --- a/singlestoredb/config.py +++ b/singlestoredb/config.py @@ -252,9 +252,9 @@ ) register_option( - 'mogrify_empty_args', 'bool', check_bool, False, + 'interpolate_query_with_empty_args', 'bool', check_bool, False, 'Should mogrify apply string interpolation when args is an empty tuple/list? ', - environ='SINGLESTOREDB_MOGRIFY_EMPTY_ARGS', + environ='SINGLESTOREDB_interpolate_query_with_empty_args', ) register_option( diff --git a/singlestoredb/connection.py b/singlestoredb/connection.py index 848d42c1e..942b2feb9 100644 --- a/singlestoredb/connection.py +++ b/singlestoredb/connection.py @@ -1118,10 +1118,10 @@ def __init__(self, **kwargs: Any): def _convert_params( cls, oper: str, params: Optional[Union[Sequence[Any], Dict[str, Any], Any]], - mogrify_empty_args: bool = False, + interpolate_query_with_empty_args: bool = False, ) -> Tuple[Any, ...]: """Convert query to correct parameter format.""" - if mogrify_empty_args: + if interpolate_query_with_empty_args: should_convert = params is not None else: should_convert = bool(params) @@ -1339,7 +1339,7 @@ def connect( enable_extended_data_types: Optional[bool] = None, vector_data_format: Optional[str] = None, parse_json: Optional[bool] = None, - mogrify_empty_args: Optional[bool] = None, + interpolate_query_with_empty_args: Optional[bool] = None, ) -> Connection: """ Return a SingleStoreDB connection. @@ -1425,7 +1425,7 @@ def connect( Should extended data types (BSON, vector) be enabled? vector_data_format : str, optional Format for vector types: json or binary - mogrify_empty_args : bool, optional + interpolate_query_with_empty_args : bool, optional Should the connector apply parameter interpolation even when the parameters are empty? This corresponds to pymysql/mysqlclient's handling diff --git a/singlestoredb/http/connection.py b/singlestoredb/http/connection.py index dec48304f..1187afad9 100644 --- a/singlestoredb/http/connection.py +++ b/singlestoredb/http/connection.py @@ -548,10 +548,12 @@ def _execute( if handler is not None: return self._execute_fusion_query(oper, params, handler=handler) - mogrify_empty_args = self._connection.connection_params.get( - 'mogrify_empty_args', False, + interpolate_query_with_empty_args = self._connection.connection_params.get( + 'interpolate_query_with_empty_args', False, + ) + oper, params = self._connection._convert_params( + oper, params, interpolate_query_with_empty_args, ) - oper, params = self._connection._convert_params(oper, params, mogrify_empty_args) log_query(oper, params) diff --git a/singlestoredb/mysql/connection.py b/singlestoredb/mysql/connection.py index 938c368b8..094fad684 100644 --- a/singlestoredb/mysql/connection.py +++ b/singlestoredb/mysql/connection.py @@ -360,7 +360,7 @@ def __init__( # noqa: C901 track_env=False, enable_extended_data_types=True, vector_data_format='binary', - mogrify_empty_args=None, + interpolate_query_with_empty_args=None, ): BaseConnection.__init__(**dict(locals())) @@ -615,7 +615,7 @@ def _config(key, arg): self._auth_plugin_map = auth_plugin_map or {} self._binary_prefix = binary_prefix self.server_public_key = server_public_key - self.mogrify_empty_args = mogrify_empty_args + self.interpolate_query_with_empty_args = interpolate_query_with_empty_args if self.connection_params['nan_as_null'] or \ self.connection_params['inf_as_null']: diff --git a/singlestoredb/mysql/cursors.py b/singlestoredb/mysql/cursors.py index 0a387afdf..2c69060c4 100644 --- a/singlestoredb/mysql/cursors.py +++ b/singlestoredb/mysql/cursors.py @@ -181,7 +181,7 @@ def mogrify(self, query, args=None): """ conn = self._get_db() - if conn.mogrify_empty_args: + if conn.interpolate_query_with_empty_args: should_interpolate = args is not None else: should_interpolate = bool(args) diff --git a/singlestoredb/tests/test_connection.py b/singlestoredb/tests/test_connection.py index ba9a88d4b..ee392d06a 100755 --- a/singlestoredb/tests/test_connection.py +++ b/singlestoredb/tests/test_connection.py @@ -3145,7 +3145,10 @@ def test_f16_vectors(self): ) def test_mogrify_val_with_percent(self): - conn = s2.connect(database=type(self).dbname, mogrify_empty_args=True) + conn = s2.connect( + database=type(self).dbname, + interpolate_query_with_empty_args=True, + ) cur = conn.cursor() val_with_percent = 'a%a' cur.execute( diff --git a/singlestoredb/utils/mogrify.py b/singlestoredb/utils/mogrify.py index 72b2b5994..5888d2f32 100644 --- a/singlestoredb/utils/mogrify.py +++ b/singlestoredb/utils/mogrify.py @@ -123,7 +123,7 @@ def mogrify( encoders: Optional[Encoders] = None, server_status: int = 0, binary_prefix: bool = False, - mogrify_empty_args: bool = False, + interpolate_query_with_empty_args: bool = False, ) -> Union[str, bytes]: """ Returns the exact string sent to the database by calling the execute() method. @@ -136,7 +136,7 @@ def mogrify( Query to mogrify. args : Sequence[Any] or Dict[str, Any] or Any, optional Parameters used with query. (optional) - mogrify_empty_args : bool, optional + interpolate_query_with_empty_args : bool, optional If True, apply string interpolation even when args is an empty tuple/list. If False, only apply when args is truthy. Defaults to False. @@ -145,7 +145,7 @@ def mogrify( str : The query with argument binding applied. """ - if mogrify_empty_args: + if interpolate_query_with_empty_args: should_interpolate = args is not None else: should_interpolate = bool(args)