Error writing to database just because of innocent input name

Error writing to database just because of innocent input name

by Martin Kraska -
Number of replies: 3

This is a problem which took half a day to find a workaround. This is how to reproduce:

  1. import the attached question.
  2. open the preview
  3. select "tidy question"
  4. try to rename S_F to S_M

I get "Error writing to database"

However, if I rename S_F to S_MM, then I can save the question. I never would have guessed that a name without any special features would be the culprit.

Can you reproduce this?

Average of ratings: -
In reply to Martin Kraska

Re: Error writing to database just because of innocent input name

by Martin Kraska -

Is the problem related to case sensitivity or lack of this?

In reply to Martin Kraska

Re: Error writing to database just because of innocent input name

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Well, if you use MySQL database, then you have to live with the strange fact that MySQL thinks that 'S_m' is equal to 'S_M', even though they are clearly different.

My preferred solution is to always use Postgres. Fiddingly your table collations to utf8_bin is another work-around. Or, just avoid variable names which differ only due to case.

https://docs.moodle.org/dev/Database_collation_issue has more info.
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Error writing to database just because of innocent input name

by Martin Kraska -

Thank you for clarifying this.

In order to increase user-friendliness of STACK, I'd propose to either suppress this issue by internal checking for conflicts in identifiers for input and feedback. It is a trade between freedom for those with a postgres database and safety for those with a mysql database. Once this seems to be a known issue, I'd appreciate being warned in the help texts about not to rely on case sensitivity in identifiers.

I just cross checked the help texts for the question text entry and the help page referenced therein. They both don't contain any hint on case sensitivity issues. Yet why should they, if the issue could be avoided at question level.

I had no idea about databases and their case sensitivity. That's why the issue took me the time worth the authoring of a whole multipart question (which due to inefficient personal workflow is several hours).

Please, dear developers, don't forget how stupid users can be!