Issue Bug Closed

#81487Quoting error for date field when building query in extbase repository

Michael Stopp 06/06/17, 17:45 updated 10/02/18, 11:00

Description

While migrating an extbase extension from 6.2 to 8.7 I noticed that the results from a custom repository query were very different (and wrong…) on T3 V8.7.
After debugging the query it turns out that the quoting for a field of type ‘date’ was wrong. The resulting SQL is now (T3 V8.7):

`tx_myext_domain_model_submissionslot`.`deadline` >= 2017

It actually should be (as it was in T3 V6.2):

`tx_myext_domain_model_submissionslot`.`deadline` >= '2017-06-06'

This will obviously generate wrong results.
The above WHERE clause was created by the following PHP code in the repository:

$query->greaterThanOrEqual('editions.submissionSlots.deadline', $start->format('Y-m-d'));

The TCA configuration for this field is:

'deadline' => array(
  'exclude' => 1,
  'label' => 'LLL:EXT:my_ext/Resources/Private/Language/locallang_db.xlf:tx_myext_domain_model_submissionslot.deadline',
  'config' => array(
    'dbType' => 'date',
    'type' => 'input',
    'renderType' => 'inputDateTime',
    'size' => 10,
    'eval' => 'date,required',
    'checkbox' => 0,
    'default' => '0000-00-00'
  ),
),

Reviews 2