Issue Bug Closed

#79304SQL error if empty datetime value is saved

Sascha Egerer 01/12/17, 22:12 updated 10/02/18, 11:03

Description

If a TCA input field of dbType datetime is saved with an empty value a SQL error is triggered.

1: These fields of record 1 in table "tx_datetimetest_domain_model_history" have not been saved correctly: date_time_native! The values might have changed due to type casting of the database.

Example configuration (from styleguide extension)

        'input_37' => [
            'exclude' => 1,
            'label' => 'input_37 dbType=datetime eval=datetime',
            'config' => [
                'dbType' => 'datetime',
                'type' => 'input',
                'size' => 20,
                'eval' => 'datetime',
                'checkbox' => 0,
                'default' => '0000-00-00 00:00:00'
            ],
        ],
2: SQL error: 'Incorrect datetime value: '0' for column 'input_37' at row 1' (tx_styleguide_elements_basic:1)

This can be reproduced with the Acceptance tests
@./bin/codecept run -f Acceptance -c components/testing_framework/core/Build/AcceptanceTests.yml typo3/sysext/core/Tests/Acceptance/Backend/Formhandler/ElementsBasicCest.php:checkThatValidationWorks_EvalDateTime_DbTypeDateTime@

They (sometimes) are successfull but the sql error message is visible for a short time

Reviews 2