Make UID validation case-sensitive

System Information
  • Strapi Version: 3.6.6 enterprise
  • Operating System: Docker Strapi/Strapi official image
  • Database: Bookshelf mariadb/10.3 Docker Image
  • Node Version: 12.20.1
  • NPM Version: 7.20.5
  • Yarn Version: n/a

I am using nanoid package on my frontend to give some of my content types a uid field in base 64. I manually inputted some test cases to see if the UID field is case-sensitive and when changing the case of letters I still get the warning “unavailable”.

i.e.

Post 1:
uid: ipvJsXG_SS_
Post 2:
uid: iPvJsXG_SS_

In this scenario, I changed the case on the second letter “P” and the strapi backend notifies me that the uid is taken. Is there a way to make UID fields case-sensitive so that I can take advantage of higher base unique id’s properly?

Hmmm interesting, based on the YUP regex rule it should be case insensitive, the only reason I can think we would make it forcefully lowercase is for some database queries where we didn’t want to have to deal with case sensitive databases (or insensitive).

Can you open a bug report? Likewise this probably needs to be tested in the v4 beta.

Ah thanks to your comment I think I’ve found the issue. :grinning: I suppose that it should be case-sensitive according to the Yup .matches regex. I checked the column in the DB and the collation was set to utf8_general_mysql500_ci. I’m not sure if this is the best course of action, but I have changed the collation for the uid column to utf8_bin and the validation on Strapi backend is now working with case-sensitivity.

My question now is whether the default collation when Strapi generates new tables in the database is influenced by Strapi or Bookshelf(i.e. Either Strapi or Bookshelf defines the collation for the table as utf8_general_mysql500_ci upon table generation) or maybe it’s just inheriting this status from the default setup of my Maria DB service?

Most likely the default from MySQL though I find it odd it was set to that as I think Default MySQL should be utf8_mb4 or maybe latin1?

Would need confirmation, (I always set mine to utf8_mb4 when I install it locally or on a server)