From fa52271b505e98dce7b084305f1805531d24af7b Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Tue, 27 Apr 2021 21:31:44 +0300 Subject: [PATCH] lookup transactions by description directly in transactions table description_history is abandoned, transactions.description uses NOCASE collation and the UPPER trickery is not needed anymore --- .../net/ktnx/mobileledger/dao/TransactionDAO.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java b/app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java index 8e0156b7..869e88c2 100644 --- a/app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java +++ b/app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java @@ -79,12 +79,11 @@ public abstract class TransactionDAO extends BaseDAO { @Query("SELECT * FROM transactions WHERE id = :transactionId") public abstract TransactionWithAccounts getByIdWithAccountsSync(long transactionId); - @Query("SELECT DISTINCT description, CASE WHEN description_upper LIKE :term||'%%' THEN 1 " + - " WHEN description_upper LIKE '%%:'||:term||'%%' THEN 2 " + - " WHEN description_upper LIKE '%% '||:term||'%%' THEN 3 " + - " ELSE 9 END AS ordering " + "FROM description_history " + - "WHERE description_upper LIKE '%%'||:term||'%%' " + - "ORDER BY ordering, description_upper, rowid ") + @Query("SELECT DISTINCT description, CASE WHEN description LIKE :term||'%%' THEN 1 " + + " WHEN description LIKE '%%:'||:term||'%%' THEN 2 " + + " WHEN description LIKE '%% '||:term||'%%' THEN 3 " + + " ELSE 9 END AS ordering FROM transactions " + + "WHERE description LIKE '%%'||:term||'%%' " + "ORDER BY ordering, description, rowid ") public abstract List lookupDescriptionSync(@NonNull String term); @androidx.room.Transaction -- 2.39.5