v8-archive icon indicating copy to clipboard operation
v8-archive copied to clipboard

Bug when use date null

Open nathannau opened this issue 4 years ago • 2 comments

Bug Report

When use calendar or date, setting as nullable, if you leave field empty, you have message : 'Failed generating the SQL query. Statement could not be executed (22007 - 1292 - Incorrect date value: '' for column 'xxxxx' at row 1)

I don't know if this job of api to cast empty string to null value, or of app to send to http://localhost/_/items/my_collec/2?fields=... (PATCH) {"my_field":""} instead of {"my_field":null}

Steps to Reproduce

  1. Create field of type date
  2. Leave 'Default Value' empty (null), and 'required' at false
  3. Create new record with field empty.

Expected Behavior

Save value 'null' in database et and toast ok

Actual Behavior

Display error message and save nothing.

Other Context & Screenshots

Api Error :

{"JSON":{"error":{"code":9,"message":"Failed generating the SQL query. Statement could not be executed (22007 - 1292 - Incorrect date value: '' for column 'fin' at row 1)","query":"UPDATE `autre_tuc` SET `label` = 'Demain', `fin` = '', `id` = '2' WHERE `id` = '2'","class":"Directus\\Database\\Exception\\InvalidQueryException","file":"/var/directus/src/core/Directus/Database/TableGateway/BaseTableGateway.php","line":847}},"Charge utile de la réponse":{"EDITOR_CONFIG":{"text":"{\"error\":{\"code\":9,\"message\":\"Failed generating the SQL query. Statement could not be executed (22007 - 1292 - Incorrect date value: '' for column 'fin' at row 1)\",\"query\":\"UPDATE `autre_tuc` SET `label` = 'Demain', `fin` = '', `id` = '2' WHERE `id` = '2'\",\"class\":\"Directus\\\\Database\\\\Exception\\\\InvalidQueryException\",\"file\":\"\\/var\\/directus\\/src\\/core\\/Directus\\/Database\\/TableGateway\\/BaseTableGateway.php\",\"line\":847}}","mode":"application/json"}}}

The value don't pass by \core\Directus\Database\Schema\Sources\MySQLSchema.php:castValue

Technical Details

  • Database: MySQL 5.7
  • Directus Release Version:
    • App Version: Last (branch master)
    • API Version: Last (branch master)
  • Install Method: cloned master branch

nathannau avatar Apr 06 '20 12:04 nathannau

@directus/team — is this API?

benhaynes avatar Apr 06 '20 13:04 benhaynes

Any news on this bug?

dzulic avatar Feb 04 '22 12:02 dzulic