yii2-enhanced-gii icon indicating copy to clipboard operation
yii2-enhanced-gii copied to clipboard

PDOException: SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value:

Open strtob opened this issue 4 years ago • 2 comments

Hi folks,

I have the tables with has many relations:

  • company
  • company_has_role
  • company_role

I've used gii enhanced to generate tables and gui with softdelete, time and userstamp.

Now, I've started to develop the update in modal view and update with ajax call.

I've dumped the model before saveAll() in the controller, model seems to be loaded correctly, but I get the following error:

Next yii\db\Exception: SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: '' The SQL being executed was: UPDATE tbl_company_has_roleSETdeleted_by=1, deleted_at='2021-05-02 02:27:56' WHERE (tbl_company_id='1') AND (id<>'') in /vendor/yiisoft/yii2/db/Schema.php:678

If I submit the ajax button without new hasmanyentries (just the master table company), the system save the data in the correct form. When I add data into the has many forms, I've got an error which pointed at vendor/mootensai/yii2-relation-trait/RelationTrait.php(228): yii\db\ActiveRecord::updateAll()

I have no idea how to fix?

Thanks in advance! Toby

strtob avatar May 02 '21 00:05 strtob

...this seems not caused by the modal function.

Also pure generated IO Model and IO Crud forms with gii enhanced without any changes produce the same error?

strtob avatar May 02 '21 01:05 strtob

I have a try with a clean generate IO Model and Crud for my person table, the has many table is company_has_person, with the same result.

All key are send in the request for the new entry by pushing the "Add" and finally update button:

Selection_007

If the strcit modus is disabled like this SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION'

The page reload without any sql exception, but the validation in the reloaded form says

`Please fix the following errors:

Company Has Person #1 : ID cannot be blank.`

Why does the saveAll() not generate an new id for the new entry in the has many table?

strtob avatar May 02 '21 11:05 strtob