1

We've just switched server for one of our sites and I am now encountering a MySql error on one of our plugins. The MySql version on the new server is 5.7 and throws an error as a field has no default value.

Do we now need to adjust our db model and records to add Null when we define the attributes to any fields that don't have a default value set?

Strange thing is when I look at the database table some fields have been set up with 'Allow Null' set and others haven't and these fields are exactly the same type for example in both model and record file I have these 2 fields one has been set to Allow Null the other hasn't??

'profession' =>  array(AttributeType::Name, 'maxLength' => 255, 'required' => false),
'city'       =>  array(AttributeType::Name, 'maxLength' => 255, 'required' => false),

Any ideas or suggestions?

Running latest craft 2.6.3016 on php 7.1

Cheers

3

The STRICT_TRANS_TABLES mode was added to the default SQL mode in MySQL 5.7.5 and is likely causing the error to be thrown:
https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html

You can either disable STRICT_TRANS_TABLES mode in your database (there are plenty of articles explaining how), or add default values to your fields (which I would recommend).

|improve this answer|||||
  • OK cheers Ben. Will look at adding the default fields. – Lettie Jun 5 '18 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.