1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

[5.0.x] Fixed #35024 -- Fixed model instance creation crash on GeneratedField.output_field with backend converters.

Regression in d9de74141e.

This is a long standing issue, however it caused a crash of
GeneratedFields for all output fields that have backend-specific
converters when the RETURNING clause is not supported
(MySQL and SQLite < 3.35).
That's why severity was exacerbated.
Backport of 5b3b791e90 from main
This commit is contained in:
Mariusz Felisiak
2023-12-07 20:50:18 +01:00
parent 454fd50efb
commit 415a08a528
4 changed files with 28 additions and 1 deletions

View File

@@ -482,6 +482,18 @@ class UUIDGrandchild(UUIDChild):
pass
class GeneratedModelFieldWithConverters(models.Model):
field = models.UUIDField()
field_copy = models.GeneratedField(
expression=F("field"),
output_field=models.UUIDField(),
db_persist=True,
)
class Meta:
required_db_features = {"supports_stored_generated_columns"}
class GeneratedModel(models.Model):
a = models.IntegerField()
b = models.IntegerField()