Issue Bug Under Review Quiet

#109572Extbase Repository Query cannot query for is null

Lina Wolf 04/14/26, 07:37 updated 10/16/26, 15:32

Description

How can I test for “NOT Null” in an Extbase Repository, where the field is a nullable date? neither one seems to do the trick:

$constraints[] = $query->greaterThan('myDate', 0);
// or
$constraints[] = $query->logicalNot($query->equals('myDate', null))

The only way to test this is to use the dbal query builder…

Following TCA snippet was used to reproduce the error:

'fromdatetime' => [
    'exclude' => true,
    'label' => 'LLL:EXT:my_ext/Resources/Private/Language/locallang_db.xlf:tx_myext_domain_model_termin.fromdatetime',
    'config' => [
        'type' => 'datetime',
        'default' => 0,
    ],
],

Then we created entries over TYPO3 backend tca form and get a 0 value in db instead of e.g. null or valid datetime obj.
In Extbase Model we used:

protected ?\DateTime $fromdatetime = null;

The problem is, the check on null is never true, because we have a default set to 0.

Reviews 1

History 58