Inserting NULL into NOT NULL columns with Default Value

后端 未结 5 1337
清酒与你
清酒与你 2021-02-15 06:16

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 06:59

    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

提交回复
热议问题