diff options
| author | Simon Charette <charette.s@gmail.com> | 2024-02-03 10:54:51 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-02-04 09:24:38 +0100 |
| commit | 3e7a30fb3a5ea38d06bbedd53e2130bf192425c7 (patch) | |
| tree | 81d11e0eff12702f57b4b2a2ea845a113bc65585 /tests/schema/tests.py | |
| parent | 741f080ab595fa34ad0d682a096026abade0dcab (diff) | |
[5.0.x] Fixed #35162 -- Fixed crash when adding fields with db_default on MySQL.
MySQL doesn't allow literal DEFAULT values to be used for BLOB, TEXT,
GEOMETRY or JSON columns and requires expression to be used instead.
Regression in 7414704e88d73dafbcfbb85f9bc54cb6111439d3.
Backport of dfc77637ea5c1aa81caa72b1cf900e6931d61b54 from main
Diffstat (limited to 'tests/schema/tests.py')
| -rw-r--r-- | tests/schema/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index a16c4a6bfe..eeaa46af06 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -2306,6 +2306,19 @@ class SchemaTests(TransactionTestCase): columns = self.column_classes(Author) self.assertEqual(columns["birth_year"][1].default, "1988") + @isolate_apps("schema") + def test_add_text_field_with_db_default(self): + class Author(Model): + description = TextField(db_default="(missing)") + + class Meta: + app_label = "schema" + + with connection.schema_editor() as editor: + editor.create_model(Author) + columns = self.column_classes(Author) + self.assertIn("(missing)", columns["description"][1].default) + @skipUnlessDBFeature( "supports_column_check_constraints", "can_introspect_check_constraints" ) |
