Skip to content

Commit 2b2110f

Browse files
committed
Remove JoinQueryset.get_quoted_query()
Pass the parameters to the DB API instead of quoting them ourselves.
1 parent ba9ac5d commit 2b2110f

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

model_utils/managers.py

+2-17
Original file line numberDiff line numberDiff line change
@@ -293,21 +293,6 @@ class SoftDeletableManager(SoftDeletableManagerMixin, models.Manager):
293293

294294
class JoinQueryset(models.QuerySet):
295295

296-
def get_quoted_query(self, query):
297-
query, params = query.sql_with_params()
298-
299-
# Put additional quotes around string.
300-
params = [
301-
f'\'{p}\''
302-
if isinstance(p, str) else p
303-
for p in params
304-
]
305-
306-
# Cast list of parameters to tuple because I got
307-
# "not enough format characters" otherwise.
308-
params = tuple(params)
309-
return query % params
310-
311296
def join(self, qs=None):
312297
'''
313298
Join one queryset together with another using a temporary table. If
@@ -349,7 +334,7 @@ def join(self, qs=None):
349334
new_qs = self.model.objects.all()
350335

351336
TABLE_NAME = 'temp_stuff'
352-
query = self.get_quoted_query(qs.query)
337+
query, params = qs.query.sql_with_params()
353338
sql = '''
354339
DROP TABLE IF EXISTS {table_name};
355340
DROP INDEX IF EXISTS {table_name}_id;
@@ -358,7 +343,7 @@ def join(self, qs=None):
358343
'''.format(table_name=TABLE_NAME, fk_column=fk_column, query=str(query))
359344

360345
with connection.cursor() as cursor:
361-
cursor.execute(sql)
346+
cursor.execute(sql, params)
362347

363348
class TempModel(models.Model):
364349
temp_key = models.ForeignKey(

0 commit comments

Comments
 (0)