From cdbf4f6f0280e57ba625b9fd3d2c0b5202f7379f Mon Sep 17 00:00:00 2001 From: Sicong Jia Date: Tue, 12 Mar 2024 09:47:09 -0700 Subject: [PATCH] Update SQL query for split parameters function --- mssql/functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mssql/functions.py b/mssql/functions.py index da498b7..2f0fd58 100644 --- a/mssql/functions.py +++ b/mssql/functions.py @@ -196,8 +196,8 @@ def mssql_split_parameter_list_as_sql(self, compiler, connection): cursor.execute(f"CREATE TABLE #Temp_params (params {parameter_data_type} {Temp_table_collation})") for offset in range(0, len(rhs_params), 1000): sqls_params = rhs_params[offset: offset + 1000] - sqls_params = ", ".join("('{}')".format(item) for item in sqls_params) - cursor.execute("INSERT INTO #Temp_params VALUES %s" % sqls_params) + sql = "INSERT INTO [#Temp_params] ([params]) VALUES " + ', '.join(['(%s)'] * len(sqls_params)) + cursor.execute(sql, sqls_params) in_clause = lhs + ' IN ' + '(SELECT params from #Temp_params)'