TYPO3-Documentation / Changelog-To-Doc

1 stars 0 forks source link

[FEATURE] Add MySQL default value support for TEXT, JSON and BLOB #896

Open TYPO3IncTeam opened 3 months ago

TYPO3IncTeam commented 3 months ago

:information_source: View this commit on Github :busts_in_silhouette: Authored by Stefan Bürk stefan@buerk.tech :heavy_check_mark: Merged by Stefan Bürk stefan@buerk.tech

Commit message

[FEATURE] Add MySQL default value support for TEXT, JSON and BLOB

Database default value configuration for TEXT, BLOB and JSON field types has been impossible to use in a cross database vendor manner due to lacking support from MySQL.

Direct default values are still unsupported, but since MySQL 8.0.13+ [1] it is possible to use a default value expression with a slightly different syntax.

TYPO3 v13.0 already raised the minimal requirement to MySQL 8.0.17 paving the way to provide a compatible way to define default values on database level now.

To align the TYPO3 Database Analyzer stack ...

This change now adds support for database level default values for TEXT, JSON and BLOB fields and is accompanied by additional tests.

NOTE: This unblocks TCA type=input default schema management.

[1] https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-13.html#mysqld-8-0-13-data-types

Resolves: #103578 Releases: main Change-Id: I61c63335b6d0edc80608c246db2e2f6dbae88223 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83556 Tested-by: core-ci typo3@b13.com Tested-by: Christian Kuhn lolli@schwarzbu.ch Reviewed-by: Garvin Hicking gh@faktor-e.de Reviewed-by: Christian Kuhn lolli@schwarzbu.ch Tested-by: Stefan Bürk stefan@buerk.tech Reviewed-by: Stefan Bürk stefan@buerk.tech Tested-by: Garvin Hicking gh@faktor-e.de

:heavy_plus_sign: Added files

13.1/Feature-103578-AddDatabaseDefaultValueSupportForTEXTBLOBAndJSONFieldTypes.rst ```rst .. include:: /Includes.rst.txt .. _feature-103578-1712678936: ========================================================================================= Feature: #103578 - Add database default value support for TEXT, BLOB and JSON field types ========================================================================================= See :issue:`103578` Description =========== Database default values for :sql:`TEXT`, :sql:`JSON` and :sql:`BLOB` fields could not be used in a cross database vendor compatible manner, for example in :file:`ext_tables.sql` or as default database scheme generation for TCA managed tables and types. Direct default values are still unsupported, but since `MySQL 8.0.13+ `__ this is possible by using default value expressions, albeit in a slightly differing syntax. Example ------- .. code-block:: sql :caption: EXT:my_extension/ext_tables.sql CREATE TABLE `tx_myextension_domain_model_entity` ( `some_field` TEXT NOT NULL DEFAULT 'default-text', `json_field` JSON NOT NULL DEFAULT '{}' ); .. code-block:: php $connection = GeneralUtility::makeInstance(ConnectionPool::class) ->getConnectionByName(ConnectionPool::DEFAULT_NAME); $connection->insert( 'tx_myextension_domain_model_entity', [ 'pid' => 123, ] ); Impact ====== Database :sql:`INSERT` queries not providing values for fields, which have defined default values, and which are not using TCA powered TYPO3 API's can be now used, and will receive database-level defined default values. This also accounts for dedicated applications operating directly on the database table. .. note:: TCA unaware API will not consider different TCA or FORM Engine default value overrides and settings. So it's good to provide the basic default both in TCA and on database-level, if manually added. .. index:: Database, ext:core ```
brotkrueml commented 3 months ago

Related: #901