1
0
mirror of https://github.com/django/django.git synced 2025-10-29 00:26:07 +00:00

Fixed #32231 -- Allowed passing None params to QuerySet.raw().

This commit is contained in:
Alexander Lyabah
2020-11-28 18:08:27 +02:00
committed by Mariusz Felisiak
parent aa3d360631
commit 415f50298f
5 changed files with 28 additions and 7 deletions

View File

@@ -818,7 +818,7 @@ class QuerySet:
# PUBLIC METHODS THAT RETURN A QUERYSET SUBCLASS #
##################################################
def raw(self, raw_query, params=None, translations=None, using=None):
def raw(self, raw_query, params=(), translations=None, using=None):
if using is None:
using = self.db
qs = RawQuerySet(raw_query, model=self.model, params=params, translations=translations, using=using)
@@ -1419,14 +1419,14 @@ class RawQuerySet:
Provide an iterator which converts the results of raw SQL queries into
annotated model instances.
"""
def __init__(self, raw_query, model=None, query=None, params=None,
def __init__(self, raw_query, model=None, query=None, params=(),
translations=None, using=None, hints=None):
self.raw_query = raw_query
self.model = model
self._db = using
self._hints = hints or {}
self.query = query or sql.RawQuery(sql=raw_query, using=self.db, params=params)
self.params = params or ()
self.params = params
self.translations = translations or {}
self._result_cache = None
self._prefetch_related_lookups = ()