]> git.ktnx.net Git - mobile-ledger.git/commitdiff
lookup transactions by description directly in transactions table
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 27 Apr 2021 18:31:44 +0000 (21:31 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 30 Apr 2021 19:20:20 +0000 (19:20 +0000)
description_history is abandoned, transactions.description uses NOCASE
collation and the UPPER trickery is not needed anymore

app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java

index 8e0156b77cf1993e29abbedabe2c9f79e14a1c94..869e88c2d28e0217d534a040cc6a7adebe963cb0 100644 (file)
@@ -79,12 +79,11 @@ public abstract class TransactionDAO extends BaseDAO<Transaction> {
     @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<DescriptionContainer> lookupDescriptionSync(@NonNull String term);
 
     @androidx.room.Transaction