From 0fff35944f469976873426bac23b0d1ce65af34a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech>
Date: Tue, 7 Mar 2023 06:21:25 +0100
Subject: [PATCH] [BUGFIX] Avoid invalid default for auto-created json field
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

With #100088 the `json` field handling has been changed from
TCA `dbType = json` to `type = json` along with automatic db
field creation, if not provided by `ext_tables.sql`.

`\TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema` has been
changed to create a native json field with the default value
of '[]' if not manually provided. MariaDB allows setting of
default value for `text` and `json`fields, the competitor
`MySQL` not. Many developers are not aware of this difference.
`doctrine/dbal` does not help to avoid invalid field defaults.

This change removes the default value for json field in the
`DefaultTcaSchema` to restore cross database compatibility
with `MySQL` again.

Resolves: #100101
Related: #100088
Releases: main
Change-Id: Id49ed0a4212386f68bf92d799abef2307cf32ac3
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78043
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Thomas Hohn <tho@gyldendal.dk>
Tested-by: Thomas Hohn <tho@gyldendal.dk>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
---
 typo3/sysext/core/Classes/Database/Schema/DefaultTcaSchema.php | 1 -
 1 file changed, 1 deletion(-)

diff --git a/typo3/sysext/core/Classes/Database/Schema/DefaultTcaSchema.php b/typo3/sysext/core/Classes/Database/Schema/DefaultTcaSchema.php
index e22d2838726a..f815ec4f9854 100644
--- a/typo3/sysext/core/Classes/Database/Schema/DefaultTcaSchema.php
+++ b/typo3/sysext/core/Classes/Database/Schema/DefaultTcaSchema.php
@@ -517,7 +517,6 @@ class DefaultTcaSchema
                     $this->quote($fieldName),
                     'json',
                     [
-                        'default' => '[]',
                         'notnull' => true,
                     ]
                 );
-- 
GitLab