mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Fixed #14786 -- Fixed get_db_prep_lookup calling get_prep_value twice if prepared is False.
Thanks homm for the report and Aramgutang and lrekucki for work on the patch.
This commit is contained in:
parent
af953c45cc
commit
f19a3669b8
2 changed files with 19 additions and 0 deletions
|
@ -663,3 +663,21 @@ class PromiseTest(test.TestCase):
|
|||
self.assertIsInstance(
|
||||
URLField().get_prep_value(lazy_func()),
|
||||
six.text_type)
|
||||
|
||||
|
||||
class CustomFieldTests(unittest.TestCase):
|
||||
|
||||
def test_14786(self):
|
||||
"""
|
||||
Regression test for #14786 -- Test that field values are not prepared
|
||||
twice in get_db_prep_lookup().
|
||||
"""
|
||||
prepare_count = [0]
|
||||
class NoopField(models.TextField):
|
||||
def get_prep_value(self, value):
|
||||
prepare_count[0] += 1
|
||||
return super(NoopField, self).get_prep_value(value)
|
||||
|
||||
field = NoopField()
|
||||
field.get_db_prep_lookup('exact', 'TEST', connection=connection, prepared=False)
|
||||
self.assertEqual(prepare_count[0], 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue