-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for default value expressions and automatically use them for longtext column default values (MySQL 8.0.13+/MariaDB 10.2.1) #1476
Comments
#615 References the other side of the coin to this issue. And the commit to address it appears to still be in effect today: While MySQL 5.7 does indeed lack support for this, versions after 8.0.13 (and MariaDB after 10.2.1) has added support for this. |
You probably need to look at Pomelo.EntityFrameworkCore.MySql/src/EFCore.MySql/Migrations/MySqlMigrationsSqlGenerator.cs Lines 1336 to 1342 in 9789873
To enable it only for certain versions you would have to add the logic to both MySqlServerVersion and MariaDbServerVersion classes. If you or anyone else would like to give it a shot we welcome contributions. |
Hi, any change to add this fix also to version 5? |
@kaupov No, we usually do not add features to patch releases of branches that are already in maintenance mode. We only add features to the next major version, so they can get proper testing before release. Since the feature is a bit more involved, it is unlikely to be backported. |
When assigning a default value to a text column code-first, via
.HasDefaultValue("test")
the default value is not set at the database. This was tested both with a normal migration resulting in a.AddColumn()
call as well as with a fresh migration resulting in a.CreateTable()
call. Both migrations generated SQL that was missing setting the default value on theSerializedTimeZoneInfo
Text column.MySQL has supported this via an expression literal
DEFAULT ('abc')
since 8.0.13https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html#data-type-defaults-explicit
MariaDB has supported setting literal defaults
DEFAULT 'abc'
and expression literalsDEFAULT ('abc')
since 10.2.1https://mariadb.com/kb/en/mariadb-1021-release-notes/
Steps to reproduce
Simplified Model
Model Builder
Generated Migration Builder
Generated SQL Script
Further technical details
MySQL version: MariaDB 10.5.9
Operating system: Windows 10 20H1 & Ubuntu 20.04 LTS
Pomelo.EntityFrameworkCore.MySql version: 5.0.8
Microsoft.AspNetCore.App version: 5.0.0
The text was updated successfully, but these errors were encountered: