Case insensitive order by with ormlite and sqlite in android

雨燕双飞 提交于 2019-12-05 08:09:00
Gray

I think what you want is to use the QueryBuilder.orderByRaw(String) method. It would look something like:

ownerDao.queryBuilder().orderByRaw("Name COLLATE NOCASE").query();

Notice the raw string does not contain the ORDER BY part of the string. To quote the javadocs:

Add raw SQL "ORDER BY" clause to the SQL query statement. This should not include the "ORDER BY".

The TEXT COLLATE NOCASE columnDefinition might work although I don't have any experience with using that at all.

Also, I would not use the orderBy("Name COLLATE NOCASE", true) answer since typically ORMLite tries to escape the column names and the quotes would be in the wrong place.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!