ER_TRUNCATED_WRONG_VALUE: Incorrect datetime value

后端 未结 2 2357
醉话见心
醉话见心 2021-02-19 06:20

So i\'ve recently completed an application for a study project. It\'s all good, and all I have left is putting the application to production.

I\'m using MySQL with Node.

2条回答
  •  佛祖请我去吃肉
    2021-02-19 07:15

    Same answer (given by @Jesper) works for error

    ERROR 1292 (22007): Truncated incorrect DOUBLE value: ''
    

    i.e. my

    select @@GLOBAL.sql_mode; -- and
    select @@SESSION.sql_mode;
    

    gives

    STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

    When I updated them to

    SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION';
    SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';
    

    my SQL inserts executed without a glitch

    This error is because of Strict SQL Mode. So Only removing STRICT_TRANS_TABLES from sql_mode is enough. for example

    SET SESSION sql_mode = 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
    

提交回复
热议问题