mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[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 in7414704e88. Backport ofdfc77637eafrom main
This commit is contained in:
committed by
Mariusz Felisiak
parent
741f080ab5
commit
3e7a30fb3a
@@ -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"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user