Inserting NULL into NOT NULL columns with Default Value

后端 未结 5 1099
没有蜡笔的小新
没有蜡笔的小新 2021-02-15 06:36

For a bit of background, we use Zend Framework 2 and Doctrine at work. Doctrine will always insert NULL for values we do not popul

5条回答
  •  太阳男子
    2021-02-15 07:19

    I came across the same problem after a MySQL upgrade. Turns out there is a setting to allow NULL inserts against NOT NULL timestamp fields and get the default value.

    explicit_defaults_for_timestamp=0
    

    This is documented at https://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_explicit_defaults_for_timestamp

提交回复
热议问题