Question

We are porting an app which formerly used Openbase 7 to now use MySQL 5.0.

OB 7 did have quite badly defined (i.e. undocumented) behavior regarding case-sensitivity. We only found this out now when trying the same queries with MySQL.

It appears that OB 7 treats lookups using "=" differently from those using "LIKE": If you have two values "a" and "A", and make a query with WHERE f="a", then it finds only the "a" field, not the "A" field. However, if you use LIKE instead of "=", then it finds both.

Our tests with MySQL showed that if we're using a non-binary collation (e.g. latin1), then both "=" and "LIKE" compare case-insensitively. However, to simulate OB's behavior, we need to get only "=" to be case-sensitive.

We're now trying to figure out how to deal with this in MySQL without having to add a lot of LOWER() function calls to all our queries (there are a lot!).

We have full control over the MySQL DB, meaning we can choose its collation mode as we like (our table names and unique indexes are not affected by the case sensitivity issues, fortunately).

Any suggestions how to simulate the OpenBase behaviour on MySQL with the least amount of code changes?

(I realize that a few smart regex replacements in our source code to add the LOWER calls might do the trick, but we'd rather find a different way)

Was it helpful?

Solution

Another idea .. does MySQL offer something like User Defined Functions? You could then write a UDF-version of like that is case insesitive (ci_like or so) and change all like's to ci_like. Probably easier to do than regexing a call to lower in ..

OTHER TIPS

These two articles talk about case sensitivity in mysql:

Both were early hits in this Google search:

I know that this is not the answer you are looking for .. but given that you want to keep this behaviour, shouldn't you explicitly code it (rather than changing some magic 'config' somewhere)?

It's probably quite some work, but at least you'd know which areas of your code are affected.

A quick look at the MySQL docs seems to indicate that this is exactly how MySQL does it:

This means that if you search with col_name LIKE 'a%', you get all column values that start with A or a.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top