OpenID error Field 'country' doesn't have a default value

Re: OpenID error Field 'country' doesn't have a default value

by Leon Stringer -
Number of replies: 2
Picture of Core developers Picture of Particularly helpful Moodlers

It looks like mdl_user.country actually should have a default value, a blank string, so if you're seeing "Field 'country' doesn't have a default value" presumably there's an issue with the way that table was created. From my site the relevant line in SHOW CREATE TABLE mdl_user is (I have MariaDB 10.3.22):

  `country` varchar(2) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',

What does your database have for this?

I attach the complete SHOW CREATE TABLE output for reference.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: OpenID error Field 'country' doesn't have a default value

by Conor Bradley -
Looking at my database I've got 

 `country` varchar(2) COLLATE utf8mb4_unicode_ci NOT NULL,


Complete SHOW CREATE TABLE output attached.


In reply to Conor Bradley

Re: OpenID error Field 'country' doesn't have a default value

by Conor Bradley -
Obviously missing the default of '' so I ran

ALTER TABLE mdl_user
ALTER Country SET DEFAULT '';

Which has resolved the issue for me - the OpenID Connect login button is able to create users successfully now.

Thank you for the steer in the right direction!