mirror of
https://github.com/django/django.git
synced 2025-10-26 23:26:08 +00:00
[5.0.x] Fixed #35149 -- Fixed crashes of db_default with unresolvable output field.
Field.db_default accepts either literal Python values or compilables (as_sql) and wrap the former ones in Value internally. While1e38f11added support for automatic resolving of output fields for types such as str, int, float, and other unambigous ones it's cannot do so for all types such as dict or even contrib.postgres and contrib.gis primitives. When a literal, non-compilable, value is provided it likely make the most sense to bind its output field to the field its attached to avoid forcing the user to provide an explicit `Value(output_field)`. Thanks David Sanders for the report. Backport ofe67d7d70fafrom main
This commit is contained in:
committed by
Mariusz Felisiak
parent
914eee1a9b
commit
761946f8e1
@@ -1310,7 +1310,7 @@ class AutodetectorTests(BaseAutodetectorTests):
|
||||
changes, "testapp", 0, 0, name="name", preserve_default=True
|
||||
)
|
||||
self.assertOperationFieldAttributes(
|
||||
changes, "testapp", 0, 0, db_default=models.Value("Ada Lovelace")
|
||||
changes, "testapp", 0, 0, db_default="Ada Lovelace"
|
||||
)
|
||||
|
||||
@mock.patch(
|
||||
@@ -1516,7 +1516,7 @@ class AutodetectorTests(BaseAutodetectorTests):
|
||||
changes, "testapp", 0, 0, name="name", preserve_default=True
|
||||
)
|
||||
self.assertOperationFieldAttributes(
|
||||
changes, "testapp", 0, 0, db_default=models.Value("Ada Lovelace")
|
||||
changes, "testapp", 0, 0, db_default="Ada Lovelace"
|
||||
)
|
||||
|
||||
@mock.patch(
|
||||
|
||||
Reference in New Issue
Block a user