mysql detects duplicate but not programming languages

Viewed 35

here in this table https://www.db-fiddle.com/f/mU8RhMyiNb6RBjdaYZztci/0

i try to insert two names girisken, girişken and for mysql this is a duplicate and the second one can not be insert because the first exists and i am fine

but in python when i do

a = 'girisken'
b = 'girişken'
print(a == b)

it gives me false and that makes problems trying to insert it to mysql

how to solve this problem?

my collation is utf8mb4_unicode_520_ci in mysql

1 Answers

Character equivalence is based on the collation.

In MySQL's default collation utf8mb4_0900_ai_ci, 's' is equal to 'ş':

mysql> select 'girisken' = 'girişken' as same;
+------+
| same |
+------+
|    1 |
+------+

I infer that this word is from the Türkçe language (I assume since the country now wants to be known as Türkiye, their language maybe should be known as Türkçe?).

So the proper collation should be chosen for that language:

mysql> select 'girisken' = 'girişken' collate utf8mb4_turkish_ci as same;
+------+
| same |
+------+
|    0 |
+------+

Or in MySQL 8.0, an updated collation is available:

mysql> select 'girisken' = 'girişken' collate utf8mb4_tr_0900_ai_ci as same;
+------+
| same |
+------+
|    0 |
+------+
Related