mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
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.
This commit is contained in:
committed by
Mariusz Felisiak
parent
d38c34119e
commit
f783a99072
@@ -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):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user