← Back to team overview

maria-discuss team mailing list archive

Re: Reading a field's default value from a trigger

 

For anyone encountering the "Field 'xxx' doesn't have a default value" when running insert/update/replace statement on MariaDB, I found that this is actually caused by the sql mode STRICT_TRANS_TABLES. This also fixes when a trigger updates the default value of the field. I believe the default options for MariaDB windows installer cause this option to be enabled, whereas I had previous never designed my application for the various modes supported.

You can also fix the issue by giving every field in the table an explicit default value of 0 or '' except for text/longtext columns. I choose not to do that since I don't know how many other things change with STRICT_TRANS_TABLES.

If you change my.ini / my.cnf to sql-mode="", you won't have this error occur anymore. You can run SELECT @@GLOBAL.sql_mode; on your mysql server and mariadb server to compare what the current settings are.

This is my first post to the MariaDB mailing list. Sorry if I did it wrong. I've been using MySQL for over 10 years and decided to migrate to MariaDB now.

--
Bruce Kirkpatrick<http://www.skyflare.com/>
386-405-4643

Follow ups