From e4e8a971af5e7264dc44a8177cecb1755653bb25 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 14 Dec 2018 05:58:37 +0000 Subject: [PATCH] proper update of accounts in DB keeping existing settings insert or replace is more like insert or delete and insert which destroys the hidden flag --- .../java/net/ktnx/mobileledger/RetrieveAccountsTask.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/RetrieveAccountsTask.java b/app/src/main/java/net/ktnx/mobileledger/RetrieveAccountsTask.java index 75c40564..8532e1ac 100644 --- a/app/src/main/java/net/ktnx/mobileledger/RetrieveAccountsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/RetrieveAccountsTask.java @@ -180,9 +180,11 @@ class RetrieveAccountsTask extends android.os.AsyncTask { do { LedgerAccount acc = new LedgerAccount(name); db.execSQL( - "insert or replace into accounts(name, name_upper, level, parent_name, keep) " - + "values(?, ?, ?, ?, 1)", - new Object[]{name, name.toUpperCase(), acc.getLevel(), acc.getParentName()}); + "update accounts set level = ?, keep = 1 where name = ?", + new Object[]{acc.getLevel(), name}); + db.execSQL("insert into accounts(name, name_upper, parent_name, level) select ?,?," + + "?,? " + "where (select changes() = 0)", + new Object[]{name, name.toUpperCase(), acc.getParentName(), acc.getLevel()}); name = acc.getParentName(); } while (name != null); } -- 2.39.5