Removed support for callable QuerySet arguments per deprecation timeline; refs #11629.
This commit is contained in:
parent
4548a282a1
commit
2cd00424c4
|
@ -27,7 +27,7 @@ from django.db.models.sql.datastructures import (
|
||||||
from django.db.models.sql.where import (WhereNode, Constraint, EverythingNode,
|
from django.db.models.sql.where import (WhereNode, Constraint, EverythingNode,
|
||||||
ExtraWhere, AND, OR, EmptyWhere)
|
ExtraWhere, AND, OR, EmptyWhere)
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.deprecation import RemovedInDjango19Warning, RemovedInDjango20Warning
|
from django.utils.deprecation import RemovedInDjango20Warning
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
from django.utils.tree import Node
|
from django.utils.tree import Node
|
||||||
|
|
||||||
|
@ -973,11 +973,6 @@ class Query(object):
|
||||||
raise ValueError("Cannot use None as a query value")
|
raise ValueError("Cannot use None as a query value")
|
||||||
lookups[-1] = 'isnull'
|
lookups[-1] = 'isnull'
|
||||||
value = True
|
value = True
|
||||||
elif callable(value):
|
|
||||||
warnings.warn(
|
|
||||||
"Passing callable arguments to queryset is deprecated.",
|
|
||||||
RemovedInDjango19Warning, stacklevel=2)
|
|
||||||
value = value()
|
|
||||||
elif hasattr(value, 'resolve_expression'):
|
elif hasattr(value, 'resolve_expression'):
|
||||||
pre_joins = self.alias_refcount.copy()
|
pre_joins = self.alias_refcount.copy()
|
||||||
value = value.resolve_expression(self, reuse=can_reuse, allow_joins=allow_joins)
|
value = value.resolve_expression(self, reuse=can_reuse, allow_joins=allow_joins)
|
||||||
|
|
|
@ -5,7 +5,6 @@ import datetime
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
import pickle
|
import pickle
|
||||||
import unittest
|
import unittest
|
||||||
import warnings
|
|
||||||
|
|
||||||
from django.core.exceptions import FieldError
|
from django.core.exceptions import FieldError
|
||||||
from django.db import connection, DEFAULT_DB_ALIAS
|
from django.db import connection, DEFAULT_DB_ALIAS
|
||||||
|
@ -15,7 +14,6 @@ from django.db.models.sql.constants import LOUTER
|
||||||
from django.db.models.sql.datastructures import EmptyResultSet
|
from django.db.models.sql.datastructures import EmptyResultSet
|
||||||
from django.test import TestCase, skipUnlessDBFeature
|
from django.test import TestCase, skipUnlessDBFeature
|
||||||
from django.test.utils import CaptureQueriesContext
|
from django.test.utils import CaptureQueriesContext
|
||||||
from django.utils.deprecation import RemovedInDjango19Warning
|
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.six.moves import range
|
from django.utils.six.moves import range
|
||||||
|
|
||||||
|
@ -1164,17 +1162,6 @@ class Queries1Tests(BaseQuerysetTest):
|
||||||
['<Author: a1>', '<Author: a2>', '<Author: a3>', '<Author: a4>']
|
['<Author: a1>', '<Author: a2>', '<Author: a3>', '<Author: a4>']
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_callable_args(self):
|
|
||||||
with warnings.catch_warnings(record=True) as w:
|
|
||||||
warnings.simplefilter('always')
|
|
||||||
qs = Tag.objects.filter(name__startswith=lambda: 't')
|
|
||||||
self.assertQuerysetEqual(
|
|
||||||
qs,
|
|
||||||
['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>']
|
|
||||||
)
|
|
||||||
self.assertEqual(len(w), 1)
|
|
||||||
self.assertTrue(issubclass(w[0].category, RemovedInDjango19Warning))
|
|
||||||
|
|
||||||
|
|
||||||
class Queries2Tests(TestCase):
|
class Queries2Tests(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in New Issue