Skip to content

Commit cb6f3ac

Browse files
Rename option
1 parent 5455c5e commit cb6f3ac

File tree

7 files changed

+21
-16
lines changed

7 files changed

+21
-16
lines changed

singlestoredb/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@
252252
)
253253

254254
register_option(
255-
'mogrify_empty_args', 'bool', check_bool, False,
255+
'interpolate_query_with_empty_args', 'bool', check_bool, False,
256256
'Should mogrify apply string interpolation when args is an empty tuple/list? ',
257-
environ='SINGLESTOREDB_MOGRIFY_EMPTY_ARGS',
257+
environ='SINGLESTOREDB_interpolate_query_with_empty_args',
258258
)
259259

260260
register_option(

singlestoredb/connection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,10 +1118,10 @@ def __init__(self, **kwargs: Any):
11181118
def _convert_params(
11191119
cls, oper: str,
11201120
params: Optional[Union[Sequence[Any], Dict[str, Any], Any]],
1121-
mogrify_empty_args: bool = False,
1121+
interpolate_query_with_empty_args: bool = False,
11221122
) -> Tuple[Any, ...]:
11231123
"""Convert query to correct parameter format."""
1124-
if mogrify_empty_args:
1124+
if interpolate_query_with_empty_args:
11251125
should_convert = params is not None
11261126
else:
11271127
should_convert = bool(params)
@@ -1339,7 +1339,7 @@ def connect(
13391339
enable_extended_data_types: Optional[bool] = None,
13401340
vector_data_format: Optional[str] = None,
13411341
parse_json: Optional[bool] = None,
1342-
mogrify_empty_args: Optional[bool] = None,
1342+
interpolate_query_with_empty_args: Optional[bool] = None,
13431343
) -> Connection:
13441344
"""
13451345
Return a SingleStoreDB connection.
@@ -1425,7 +1425,7 @@ def connect(
14251425
Should extended data types (BSON, vector) be enabled?
14261426
vector_data_format : str, optional
14271427
Format for vector types: json or binary
1428-
mogrify_empty_args : bool, optional
1428+
interpolate_query_with_empty_args : bool, optional
14291429
Should the connector apply parameter interpolation even when the
14301430
parameters are empty? This corresponds to pymysql/mysqlclient's handling
14311431

singlestoredb/http/connection.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,12 @@ def _execute(
548548
if handler is not None:
549549
return self._execute_fusion_query(oper, params, handler=handler)
550550

551-
mogrify_empty_args = self._connection.connection_params.get(
552-
'mogrify_empty_args', False,
551+
interpolate_query_with_empty_args = self._connection.connection_params.get(
552+
'interpolate_query_with_empty_args', False,
553+
)
554+
oper, params = self._connection._convert_params(
555+
oper, params, interpolate_query_with_empty_args,
553556
)
554-
oper, params = self._connection._convert_params(oper, params, mogrify_empty_args)
555557

556558
log_query(oper, params)
557559

singlestoredb/mysql/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def __init__( # noqa: C901
360360
track_env=False,
361361
enable_extended_data_types=True,
362362
vector_data_format='binary',
363-
mogrify_empty_args=None,
363+
interpolate_query_with_empty_args=None,
364364
):
365365
BaseConnection.__init__(**dict(locals()))
366366

@@ -615,7 +615,7 @@ def _config(key, arg):
615615
self._auth_plugin_map = auth_plugin_map or {}
616616
self._binary_prefix = binary_prefix
617617
self.server_public_key = server_public_key
618-
self.mogrify_empty_args = mogrify_empty_args
618+
self.interpolate_query_with_empty_args = interpolate_query_with_empty_args
619619

620620
if self.connection_params['nan_as_null'] or \
621621
self.connection_params['inf_as_null']:

singlestoredb/mysql/cursors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def mogrify(self, query, args=None):
181181
"""
182182
conn = self._get_db()
183183

184-
if conn.mogrify_empty_args:
184+
if conn.interpolate_query_with_empty_args:
185185
should_interpolate = args is not None
186186
else:
187187
should_interpolate = bool(args)

singlestoredb/tests/test_connection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3145,7 +3145,10 @@ def test_f16_vectors(self):
31453145
)
31463146

31473147
def test_mogrify_val_with_percent(self):
3148-
conn = s2.connect(database=type(self).dbname, mogrify_empty_args=True)
3148+
conn = s2.connect(
3149+
database=type(self).dbname,
3150+
interpolate_query_with_empty_args=True,
3151+
)
31493152
cur = conn.cursor()
31503153
val_with_percent = 'a%a'
31513154
cur.execute(

singlestoredb/utils/mogrify.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def mogrify(
123123
encoders: Optional[Encoders] = None,
124124
server_status: int = 0,
125125
binary_prefix: bool = False,
126-
mogrify_empty_args: bool = False,
126+
interpolate_query_with_empty_args: bool = False,
127127
) -> Union[str, bytes]:
128128
"""
129129
Returns the exact string sent to the database by calling the execute() method.
@@ -136,7 +136,7 @@ def mogrify(
136136
Query to mogrify.
137137
args : Sequence[Any] or Dict[str, Any] or Any, optional
138138
Parameters used with query. (optional)
139-
mogrify_empty_args : bool, optional
139+
interpolate_query_with_empty_args : bool, optional
140140
If True, apply string interpolation even when args is an empty tuple/list.
141141
If False, only apply when args is truthy. Defaults to False.
142142
@@ -145,7 +145,7 @@ def mogrify(
145145
str : The query with argument binding applied.
146146
147147
"""
148-
if mogrify_empty_args:
148+
if interpolate_query_with_empty_args:
149149
should_interpolate = args is not None
150150
else:
151151
should_interpolate = bool(args)

0 commit comments

Comments
 (0)