From 49c93c4466da6754bfd63495cdff274935ca235e Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 24 Apr 2021 23:49:57 +0300 Subject: [PATCH] restore account ordering by name it was nice to use the ordering from hledger, but after the migration to room this worked only by chance - sqlite returned the rows in the order they were inserted. this means that any new accounts will end up at the bottom. this is the case when speculative transaction storage is active (coming soon) and the transaction has a new account. also, the conversion from db account objects to UI list relies on the ordering now. in a future version, the accounts table may store the hledger ordering in a new column, but this doesn't completely solve the problem when adding new accounts speculatively --- app/src/main/java/net/ktnx/mobileledger/dao/AccountDAO.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/dao/AccountDAO.java b/app/src/main/java/net/ktnx/mobileledger/dao/AccountDAO.java index f37b940b..429e1643 100644 --- a/app/src/main/java/net/ktnx/mobileledger/dao/AccountDAO.java +++ b/app/src/main/java/net/ktnx/mobileledger/dao/AccountDAO.java @@ -75,11 +75,11 @@ public abstract class AccountDAO extends BaseDAO { @Delete public abstract void deleteSync(List items); - @Query("SELECT * FROM accounts WHERE profile_id=:profileId") + @Query("SELECT * FROM accounts WHERE profile_id=:profileId ORDER BY name") public abstract LiveData> getAll(long profileId); @Transaction - @Query("SELECT * FROM accounts WHERE profile_id = :profileId") + @Query("SELECT * FROM accounts WHERE profile_id = :profileId ORDER BY name") public abstract LiveData> getAllWithAmounts(long profileId); @Query("SELECT * FROM accounts WHERE id=:id") -- 2.39.5