Use COLLATE NOCASE for browse queries

This commit is contained in:
Kai Elwert 2010-08-14 11:55:11 +02:00 committed by Julien BLACHE
parent 9f70adb1d1
commit dce9eb8d1f

View File

@ -1047,10 +1047,10 @@ db_build_query_browse(struct query_params *qp, char *field, char **q)
int ret; int ret;
if (qp->filter) if (qp->filter)
count = sqlite3_mprintf("SELECT COUNT(DISTINCT %s) FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != '' AND %s;", count = sqlite3_mprintf("SELECT COUNT(DISTINCT %s COLLATE NOCASE) FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != '' AND %s;",
field, field, qp->filter); field, field, qp->filter);
else else
count = sqlite3_mprintf("SELECT COUNT(DISTINCT %s) FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != '';", count = sqlite3_mprintf("SELECT COUNT(DISTINCT %s COLLATE NOCASE) FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != '';",
field, field); field, field);
if (!count) if (!count)
@ -1072,16 +1072,16 @@ db_build_query_browse(struct query_params *qp, char *field, char **q)
return -1; return -1;
if (idx && qp->filter) if (idx && qp->filter)
query = sqlite3_mprintf("SELECT DISTINCT %s FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''" query = sqlite3_mprintf("SELECT DISTINCT %s COLLATE NOCASE FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''"
" AND %s %s;", field, field, qp->filter, idx); " AND %s %s;", field, field, qp->filter, idx);
else if (idx) else if (idx)
query = sqlite3_mprintf("SELECT DISTINCT %s FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''" query = sqlite3_mprintf("SELECT DISTINCT %s COLLATE NOCASE FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''"
" %s;", field, field, idx); " %s;", field, field, idx);
else if (qp->filter) else if (qp->filter)
query = sqlite3_mprintf("SELECT DISTINCT %s FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''" query = sqlite3_mprintf("SELECT DISTINCT %s COLLATE NOCASE FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''"
" AND %s;", field, field, qp->filter); " AND %s;", field, field, qp->filter);
else else
query = sqlite3_mprintf("SELECT DISTINCT %s FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''", query = sqlite3_mprintf("SELECT DISTINCT %s COLLATE NOCASE FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''",
field, field); field, field);
if (!query) if (!query)