Project

General

Profile

Actions

Bug #88331

closed

MySQL strict mode: let integer time fields be filled with NULL

Added by Hagen Gebauer over 5 years ago. Updated 8 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2019-05-10
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.3
Tags:
persistence
Complexity:
Is Regression:
Sprint Focus:

Description

I have an events extension with the following fields

date_start date NULL DEFAULT NULL,
date_end date NULL DEFAULT NULL,
time_start int(11) NULL DEFAULT NULL,
time_end int(11) NULL DEFAULT NULL,

The only required field is date_start so that it is possible to add events without defining a specific start time. The end time is rarely used anyway.

I want to be able to send both time fields with an empty value instead of '0' but that returns an SQL error on submitting the backend form when MySQL is in strict mode (and it clears the whole form, to boot). For the date_end field this works and will be stored as NULL. For now I go with the default value '0' and assume that '00:00' is an empty time field and no event starts at midnight – but that doesn’t feel right.

If this isn’t a TYPO3 bug and/or there is another way to achieve what I want, I apologise. But when adding a row via mysql> with empty values for the time fields they will be stored as NULL – just as I want it.

The TCA for the fields is

'date_start' => [
    'exclude' => true,
    'l10n_mode' => 'exclude',
    'label' => '' . $locLang . 'events.date_start',
    'config' => [
        'dbType' => 'date',
        'type' => 'input',
        'renderType' => 'inputDateTime',
        'size' => 7,
        'eval' => 'date, required',
        'default' => NULL
    ],
],
'date_end' => [
    'exclude' => true,
    'l10n_mode' => 'exclude',
    'label' => '' . $locLang . 'events.date_end',
    'config' => [
        'dbType' => 'date',
        'type' => 'input',
        'renderType' => 'inputDateTime',
        'size' => 7,
        'eval' => 'date',
        'default' => NULL
    ],
],
'time_start' => [
    'exclude' => true,
    'l10n_mode' => 'exclude',
    'label' => '' . $locLang . 'events.time_start',
    'config' => [
        'type' => 'input',
        'renderType' => 'inputDateTime',
        'size' => 4,
        'eval' => 'time',
        'default' => 0,
    ]
],
'time_end' => [
    'exclude' => true,
    'l10n_mode' => 'exclude',
    'label' => '' . $locLang . 'events.time_end',
    'config' => [
        'type' => 'input',
        'renderType' => 'inputDateTime',
        'size' => 4,
        'eval' => 'time',
        'default' => 0,
    ]
],

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Feature #91688: TCA: Make default value mandatory for some field types if SQL field defined as "NOT NULL" - avoid error in extensions due to strict and missing defaultClosed2020-06-22

Actions
Actions

Also available in: Atom PDF