diff options
| author | Simon Charette <charette.s@gmail.com> | 2020-07-12 00:49:43 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-07-14 07:20:20 +0200 |
| commit | f783a990725fbfce17ef827d3b55ef702535ae96 (patch) | |
| tree | dad021e54a9e15ac84af2dac4a3ec3539e0bc933 /tests | |
| parent | d38c34119e91a533c797098f150abe99b5ee2fd8 (diff) | |
Refs #25425 -- Allowed unresolved Value() instances to be compiled.
Previously unresolved Value() instances were only allowed to be
compiled if they weren't initialized with an output_field.
Given the usage of unresolved Value() instances is relatively common in
as_sql() overrides it's less controversial to add explicit support for
this previously undefined behavior now and revisit whether or not it
should be deprecated in the future.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/expressions/tests.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 47a410268e..42b8c8f34b 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -1703,6 +1703,14 @@ class ValueTests(TestCase): with self.assertRaisesMessage(ValueError, msg): ExpressionList() + def test_compile_unresolved(self): + # This test might need to be revisited later on if #25425 is enforced. + compiler = Time.objects.all().query.get_compiler(connection=connection) + value = Value('foo') + self.assertEqual(value.as_sql(compiler, connection), ('%s', ['foo'])) + value = Value('foo', output_field=CharField()) + self.assertEqual(value.as_sql(compiler, connection), ('%s', ['foo'])) + class FieldTransformTests(TestCase): |
