1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

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.
This commit is contained in:
Mariusz Felisiak
2023-12-07 20:50:18 +01:00
committed by GitHub
parent 2dca98f4f7
commit 5b3b791e90
4 changed files with 28 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
import uuid
from django.apps import apps
from django.db import IntegrityError, connection
from django.db.models import (
@@ -14,6 +16,7 @@ from django.test.utils import isolate_apps
from .models import (
GeneratedModel,
GeneratedModelFieldWithConverters,
GeneratedModelNull,
GeneratedModelNullVirtual,
GeneratedModelOutputFieldDbCollation,
@@ -266,6 +269,11 @@ class StoredGeneratedFieldTests(GeneratedFieldTestMixin, TestCase):
output_field_db_collation_model = GeneratedModelOutputFieldDbCollation
params_model = GeneratedModelParams
def test_create_field_with_db_converters(self):
obj = GeneratedModelFieldWithConverters.objects.create(field=uuid.uuid4())
obj = self._refresh_if_needed(obj)
self.assertEqual(obj.field, obj.field_copy)
@skipUnlessDBFeature("supports_virtual_generated_columns")
class VirtualGeneratedFieldTests(GeneratedFieldTestMixin, TestCase):