]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/dao/AccountDAO.java
methods for deleting all DB tables
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / dao / AccountDAO.java
index 0cfed1b64c2e5ad4d13845197839069356a54c80..0c581787a30a2fac55c605674904eebdd7441995 100644 (file)
@@ -75,6 +75,9 @@ public abstract class AccountDAO extends BaseDAO<Account> {
     @Delete
     public abstract void deleteSync(List<Account> items);
 
+    @Query("DELETE FROM accounts")
+    public abstract void deleteAllSync();
+
     @Query("SELECT * FROM accounts WHERE profile_id=:profileId ORDER BY name")
     public abstract LiveData<List<Account>> getAll(long profileId);
 
@@ -119,6 +122,7 @@ public abstract class AccountDAO extends BaseDAO<Account> {
     public abstract List<AccountNameContainer> lookupNamesInProfileByNameSync(long profileId,
                                                                               @NonNull String term);
 
+    @Transaction
     @Query("SELECT * FROM accounts " +
            "WHERE profile_id=:profileId AND name_upper LIKE '%%'||:term||'%%' " +
            "ORDER BY  CASE WHEN name_upper LIKE :term||'%%' THEN 1 " +
@@ -126,8 +130,7 @@ public abstract class AccountDAO extends BaseDAO<Account> {
            "               WHEN name_upper LIKE '%% '||:term||'%%' THEN 3 " +
            "               ELSE 9 END, name_upper, rowid ")
     public abstract List<AccountWithAmounts> lookupWithAmountsInProfileByNameSync(long profileId,
-                                                                                  @NonNull
-                                                                                          String term);
+                                                                                  @NonNull String term);
 
     @Query("SELECT DISTINCT name, CASE WHEN name_upper LIKE :term||'%%' THEN 1 " +
            "               WHEN name_upper LIKE '%%:'||:term||'%%' THEN 2 " +