Bug 104610 - Case-insensitive search in collection browser broken
Summary: Case-insensitive search in collection browser broken
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-26 21:15 UTC by Alexander Klyubin
Modified: 2006-06-11 12:32 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Klyubin 2005-04-26 21:15:33 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    Gentoo Packages
Compiler:          GCC 3.3.3 
OS:                Linux

Collection browser can filter songs according to space separated terms. The filter is supposed to be case-insensitive. The problem is that though the filter is case-insensitive for latin characters, it seems to be case-sensitive for cyrillic characters. I suspect this might generalize to any non-latin alphabet characters.

I observed the bug with an April 23rd 2005 CVS build of amarok. The bug is there both with SQLite and MySQL (version 4.0.24) as backends.

Amarok's playlist properly filters cyrillic song titles in a case-insensitive way. The case-insensitive filter in the playlist uses .lower() == .lower() approach. Collection browser, on the other hand, delegates the filtering to the database using LIKE operator, which is case-insensitive by default. I suspect the bug in the filter may be due to the way Amarok stores non-latin characters in the database.
Comment 1 Alexander Klyubin 2005-04-28 19:53:44 UTC
Amarok stores data in the database in UTF-8 encoding. It turned out that MySQL did not support UTF-8 encoding before version 4.1. Thus, case-insensitive comparison operations (LIKE in this case) could not work properly with non latin1 characters.

I've upgraded MySQL to 4.1.8 and configured it to use UTF-8 by default on the server side. Then, I modified amarok's code to tell MySQL that Amarok also uses UTF-8 encoding. Finally, I let Amarok create a new database. Everything works fine now. Collection browser does proper case-insensitive filtering for latin characters and for cyrillic characters.

The only problem is that this fix works only for MySQL case and only if one uses MySQL 4.1+.

---
There are two ways to make MySQL use UTF-8 on the server side:
1. Add two lines in /etc/mysql/my.cnf under [mysqld] section:
    character-set-server = utf8
    collation-server = utf8_general_ci
OR
2. Tell that Amarok's database uses UTF-8 explicitly, passing CHARACTER SET and COLLATE arguments to CREATE DATABASE or ALTER DATABASE.

---
To tell MySQL that Amarok uses UTF-8 I added following code in MySqlConnection::MySqlConnection after mysql_init and before mysql_real_connect:

if ( mysql_options( m_db, MYSQL_SET_CHARSET_NAME, QString("utf8").latin1() ) ) {
    error() << "Failed to set charset to utf8\n";
}
Comment 2 Alexandre Oliveira 2005-09-23 03:39:32 UTC
Collection Browser items are now properly sorted.
Comment 3 Stanislav Nikolov 2005-10-24 19:36:48 UTC
I notice the same bug with amarok 1.3.4 and sqlite 3.2.7 as backend.