Download & Extend

Case sensitivity (uppercase and lowercase should not be considered unique)

Project:Unique field
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

I'm using this module to create book reviews submitted by members. So the title has to be unique. the problem is sometimes they don't type it correctly (uppercase and lowercase). for example, I submit a book review entitled "Siddhartha" and other user submit the same book entitled "siddhartha", unique field consider them as a different value.

is it possible to add an option for uppercase and lowercase letters? so they are considered same value.

thanks a lot, a really unique module :)

Comments

#1

Title:uppercase and lowercase titles are considered unique?» Case sensitivity (uppercase and lowercase should not be considered unique)
Category:feature request» bug report
Status:active» needs work

Hi ascetic,

Thanks for reporting this issue.

My intention is that this module does case-insensitive comparisons by default, so that 'Siddhartha' and 'siddhartha' are considered duplicate values. This is how the module works for me.

However, whether the comparison is case-sensitive or not may depend on your database software and configuration. For example, MySQL performs this comparison without case-sensitivity only since version 4.0. What database are you using?

In a future version I'd like to make this behavior explicit and provide the option to use case-sensitive comparisons if preferred.

#2

Hi detour,

the question of case sensitivity in MySQL is even more complex because it does not only depend on the version (I guess a minimum version is required) but also on the collation setting of the column in question.

Collations can also implement specific rules to accomodate requirements from different languages:
* the characters that correspond to each other (upper/lower case); IIRC in Turkish the uppercase character of "i" is not "I" but a separate character.
* other rules like "ü" == "y" (Swedish rule) or "ß" == "ss" (German rule); and what's worse, the latter one has even changed between MySQL 5.0 and 5.1 (for collation utf8_general_ci).

In an ideal world the check done in the module would always be identical to the check done by the underlying MySQL column that gets to store the value. But I'm not sure how this could be achieved.

#3

Keeping track of this thread...

#4

The patch here might do the job for you. I'd really appreciate as many testers as possible, but it's a pretty major overhaul of how Unique Field works, so use with caution in production.

#5

This is strange. I have the opposite problem.
Node title comparison is not case sensitive in my Drupal setup. To make things worse characters with accents are treated as equal to the pairs without accents (e.g. é=e, ő=o, etc.), which is clearly wrong.

The problem is caused by MySQL case sensitivity in string searches that depends on the type of the string column.

The solution is to use the BINARY Operator: $qwhere = "BINARY node.title = '". db_escape_string($values) ."' ";

I've created a new issue for the problem of accented characters: #1306276: Wrong comparison of accented characters in strings