feat: added config value to force certain behaviour & added a note to the docs

This commit is contained in:
Sergey Shevchenko 2021-04-23 15:10:45 +12:00
parent 2c9ba8bc45
commit e68e65badc
2 changed files with 14 additions and 0 deletions

View File

@ -113,6 +113,16 @@ remove the new collation configuration to default back to the previous default c
In MySQL versions >=5.7.5, the `ANSI` sql_mode setting behaves differently and includes the `ONLY_FULL_GROUP_BY` setting. It is generally recommended to leave this setting as-is because it results in deterministic SQL. However, for some advanced cases, the sql_mode can now be configured on the database connection via the configuration API (see `MySQLDatabase::$sql_mode` for more details.)
### MySQL/MariaDB Int width in schema
MySQL 8.0.17 stopped reporting the width attribute for integers while MariaDB did not change its behaviour.
This results in constant rebuilding the schema when MySQLSchemaManager expects a field to look like i.e.
`INT(8)` and MySQL server reports it simply as `INT`. MySQLSchemaManager has been updated to detect the MySQL
server implementation and act accordingly. In cases when auto-detection fails, you can force the desired behaviour like this:
```yml
SilverStripe\ORM\Connect\MySQLSchemaManager:
schema_use_int_width: true # or false when INT widths should be ignored
```
### Flysystem dependency shifted
Previously the Flysystem package was pulled in via the `silverstripe/framework` module, but only

View File

@ -246,6 +246,10 @@ class MySQLSchemaManager extends DBSchemaManager
// MySQL 8.0.17 stopped reporting the width attribute for integers
// https://github.com/silverstripe/silverstripe-framework/issues/9453
// Note: MariaDB did not change its behaviour
$forceWidth = Config::inst()->get(self::class, 'schema_use_int_width');
if ($forceWidth !== null) {
return $forceWidth;
}
$v = $this->database->getVersion();
if (false !== strpos($v, 'MariaDB')) {
// MariaDB is included in the version string: https://mariadb.com/kb/en/version/