Bug #88515
Updated by Mathias Brodala over 2 years ago
Given an Extbase domain model with a @DateTime@ property and a DB field declared as usual: my_date int(11) unsigned DEFAULT '0' NOT NULL Setting a value here from a Fluid form works fine and the date is stored as timestamp in the DB. However, when trying to clear this property, an @SqlException@ occurs: > (1/1) #1470230767 TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\SqlErrorException > Column 'my_date' cannot be null > > in /.../typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php line 197 The error occurs when @Backend::persistObject()@ calls @DataMapper::getPlainValue()@ with the current @null@ value for the @DateTime@ property and thus gets a string @"NULL"@ in return. This then fails because @null@ values are not allowed here in SQL. An override of @AbstractDomainObject::_getProperties()@ with a fallback to @0@ (zero) for date properties works around the issue, however this should be fixed in Extbase itself: <pre><code class="php"> public function _getProperties(): array { $properties = parent::_getProperties(); $properties['myDate'] $properties['dateProperty'] ??= 0; return $properties; } </code></pre>