From: Damyan Ivanov Date: Tue, 27 Apr 2021 18:31:44 +0000 (+0300) Subject: lookup transactions by description directly in transactions table X-Git-Tag: v0.18.0~11 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=fa52271b505e98dce7b084305f1805531d24af7b;p=mobile-ledger.git 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 --- 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