From ba0a859188fd73f1d9f906099c11f2f76f4baf02 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech>
Date: Mon, 13 Mar 2023 14:53:42 +0100
Subject: [PATCH] [BUGFIX] Avoid "field doesn't have a default value" sql error
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Creating new `ext:reactions` records are broken and emits an
sql error message. This happens when it's tried to switch to
the core-shipped type.

>> 2: SQL error: "Field 'fields' doesn't have a default value"

Using a default value on database level does not work with
all database backends TYPO3 v12 officially supports, which
has been tried with #100088 and mitigated with #100101. So
that's not an option here.

This change bakes the default value for `json` type fields
using TCA default setting again, which has been the way the
original `type=user dbType=JSON` variant used with #99226.

Resolves: #100154
Related: #100101
Related: #100088
Related: #99226
Related: #99062
Releases: main
Change-Id: I07533f36cfbc1f627b14727195bbcbd5c4b1e35c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78107
Tested-by: Frank Nägler <frank.naegler@typo3.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Nikita Hovratov <nikita.h@live.de>
Reviewed-by: Frank Nägler <frank.naegler@typo3.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Nikita Hovratov <nikita.h@live.de>
---
 .../Configuration/TCA/Overrides/sys_reaction_create_record.php   | 1 +
 1 file changed, 1 insertion(+)

diff --git a/typo3/sysext/reactions/Configuration/TCA/Overrides/sys_reaction_create_record.php b/typo3/sysext/reactions/Configuration/TCA/Overrides/sys_reaction_create_record.php
index ec99b2b2677b..7fdd9868deb7 100644
--- a/typo3/sysext/reactions/Configuration/TCA/Overrides/sys_reaction_create_record.php
+++ b/typo3/sysext/reactions/Configuration/TCA/Overrides/sys_reaction_create_record.php
@@ -20,6 +20,7 @@
             'config' => [
                 'type' => 'json',
                 'renderType' => 'fieldMap',
+                'default' => '{}',
             ],
         ],
     ]
-- 
GitLab