doctrine / migrations

Doctrine Database Migrations Library
https://www.doctrine-project.org/projects/migrations.html
MIT License
4.68k stars 385 forks source link

BLOB, TEXT, GEOMETRY or JSON column '<name>' can't have a default value #1344

Open malc0mn opened 1 year ago

malc0mn commented 1 year ago

Bug Report

Q A
BC Break no (actually not sure)
Version 3.6.0

Summary

When setting a default value to a property mapped as json, the migration created on MySQL 8.0.33 will be faulty. The default value for BLOB, TEXT, GEOMETRY or JSON must be written as an expression, see https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html section Explicit Default Handling as of MySQL 8.0.13

Current behavior

Generated migration with a mapping of json and default value of '[]' generates this migration:

[...] my_column_name JSON DEFAULT \'[]\' NOT NULL [...]

How to reproduce

Simply create a mapping of type json with default value '[]' and generate a migration.

Expected behavior

Generated migration with a mapping of json and default value of '[]' should generate this migration (note the added parenthesis):

[...] my_column_name JSON DEFAULT (\'[]\') NOT NULL [...]