diff options
| author | Tim Graham <timograham@gmail.com> | 2013-08-29 11:09:58 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-08-29 12:14:40 -0400 |
| commit | 10d15f79e5e2ca7b733e2bf1860e1778c3a712dc (patch) | |
| tree | 1f7b19dab15a065fc1e5713dc1afa90f950316cf /tests/model_fields | |
| parent | ef1259342b46cd4b63678a4acddf2a2b631d342c (diff) | |
[1.6.x] 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.
Backport of f19a3669b8 from master
Diffstat (limited to 'tests/model_fields')
| -rw-r--r-- | tests/model_fields/tests.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py index 1fb5037625..432984f6bb 100644 --- a/tests/model_fields/tests.py +++ b/tests/model_fields/tests.py @@ -494,3 +494,21 @@ class GenericIPAddressFieldTests(test.TestCase): model_field = models.GenericIPAddressField(protocol='IPv6') form_field = model_field.formfield() self.assertRaises(ValidationError, form_field.clean, '127.0.0.1') + + +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) |
