Swedish sort order not working

Hi all,

I have a MySQL DB in my production environment with collation set to
latin1_swedish_ci

When I do a simple find and order by ‘name’ the names are not sorted
in Swedish order. They are “Anna, Östen, Kalle, Rut” when they should
be “Anna, Kalle, Rut, Östen”.

I guess a simple sort shall work without having to alter the table to
utf8?

Any idears?

jeb wrote:

Hi all,

I have a MySQL DB in my production environment with collation set to
latin1_swedish_ci

This is not a Rails question; it is a MySQL question. You’ll get better
answers in a MySQL forum. But…

My recollection is that not just the DB but also each table and each
field in MySQL can have its own sort order. Make sure these are all set
properly.

When I do a simple find and order by ‘name’ the names are not sorted
in Swedish order. They are “Anna, �sten, Kalle, Rut” when they should
be “Anna, Kalle, Rut, �sten”.

I guess a simple sort shall work without having to alter the table to
utf8?

You really should alter the table to UTF8. That way you’ll be able to
handle any conceivable character.

Any idears?

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On Sat, Jun 12, 2010 at 7:11 AM, jeb [email protected] wrote:

I have a MySQL DB in my production environment with collation set to
latin1_swedish_ci

When I do a simple find and order by ‘name’ the names are not sorted
in Swedish order. They are “Anna, Östen, Kalle, Rut” when they should
be “Anna, Kalle, Rut, Östen”.

If you run the query generated by ActiveRecord manually in a MySQL
console, do you get the result you expect?


Hassan S. ------------------------ [email protected]
twitter: @hassan

On Sat, Jun 12, 2010 at 8:32 AM, jeb [email protected] wrote:

If you run the query generated by ActiveRecord manually in a MySQL
console, do you get the result you expect?

No, I get the wrong result.

Can you construct a query that does return the result you expect?

What do the following commands show?

mysql> show variables like ‘%collation%’;

mysql> show variables like ‘%char%’;


Hassan S. ------------------------ [email protected]
twitter: @hassan

No, I get the wrong result.

On 12 Juni, 16:50, Hassan S. [email protected]