mootensai / yii2-enhanced-gii

Enhanced Yii2 Gii (generator) that generates related Models & CRUD
MIT License
203 stars 99 forks source link

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

Open strtob opened 3 years ago

strtob commented 3 years ago

Hi folks,

I have the tables with has many relations:

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: UPDATEtbl_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 commented 3 years ago

...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 commented 3 years ago

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?