mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-23 13:26:15 +03:00
Bug fixed: search Category fails
This commit is contained in:
parent
4a23044253
commit
d7b0352fb5
1 changed files with 5 additions and 24 deletions
|
@ -428,31 +428,12 @@ public class NotesDatabase extends AbstractNotesDatabase {
|
|||
String category_accountId = String.format("%s.%s", table_category, key_account_id);
|
||||
String rawQuery;
|
||||
|
||||
Cursor cursor;
|
||||
if (search == null || search.trim().equals("")) {
|
||||
rawQuery = "SELECT " + category_title + ", COUNT(*) FROM " + table_category + " INNER JOIN " + table_notes +
|
||||
" ON " + note_title + " = " + category_id + " WHERE " + key_status + " != ? AND " + category_accountId +
|
||||
" = ? AND " + category_title + " != \"\" GROUP BY " + category_id;
|
||||
rawQuery = "SELECT " + category_title + ", COUNT(*) FROM " + table_category + " INNER JOIN " + table_notes +
|
||||
" ON " + note_title + " = " + category_id + " WHERE " + key_status + " != ? AND " + category_accountId +
|
||||
" = ? AND " + category_title + " LIKE ? AND " + category_title + " != \"\" GROUP BY " + category_id;
|
||||
|
||||
cursor = getReadableDatabase().rawQuery(rawQuery, new String[]{DBStatus.LOCAL_DELETED.getTitle(), String.valueOf(accountId)});
|
||||
// rawQuery = String.format("SELECT %s, COUNT(*) FROM %s INNER JOIN %s ON %s = %s " +
|
||||
// " WHERE %s != '%s' AND %s = %s AND %s != \"\" GROUP BY %s",
|
||||
// category_title, table_category, table_notes, category_id, note_title,
|
||||
// key_status, DBStatus.LOCAL_DELETED.getTitle(), category_accountId, String.valueOf(accountId),
|
||||
// category_title, category_id);
|
||||
} else {
|
||||
rawQuery = "SELECT " + category_title + ", COUNT(*) FROM " + table_category + " INNER JOIN " + table_notes +
|
||||
" ON " + note_title + " = " + category_id + " WHERE " + key_status + " != ? AND " + category_accountId +
|
||||
" = ? AND " + category_title + " LIKE ? AND " + category_title + " != \"\" GROUP BY " + category_id;
|
||||
|
||||
cursor = getReadableDatabase().rawQuery(rawQuery,
|
||||
new String[]{DBStatus.LOCAL_DELETED.getTitle(), "'%" + search.trim() + "%'", String.valueOf(accountId)});
|
||||
// rawQuery = String.format("SELECT %s, COUNT(*) FROM %s INNER JOIN %s ON %s = %s " +
|
||||
// " WHERE %s != '%s' AND %s = %s AND %s LIKE %s AND %s != \"\" GROUP BY %s",
|
||||
// category_title, table_category, table_notes, category_id, note_title,
|
||||
// key_status, DBStatus.LOCAL_DELETED.getTitle(), category_accountId, String.valueOf(accountId),
|
||||
// category_title, "'%" + search.trim() + "%'", category_title, category_id);
|
||||
}
|
||||
Cursor cursor = getReadableDatabase().rawQuery(rawQuery,
|
||||
new String[]{DBStatus.LOCAL_DELETED.getTitle(), String.valueOf(accountId), "%" + (search == null ? null : search.trim()) + "%"});
|
||||
List<NavigationAdapter.NavigationItem> categories = new ArrayList<>(cursor.getCount());
|
||||
while (cursor.moveToNext()) {
|
||||
Resources res = getContext().getResources();
|
||||
|
|
Loading…
Reference in a new issue