简体   繁体   中英

Sugar orm update bug

I'm new to data base and therefore I preferred to use Sugar ORM instead of SQLite in my android project.

But there is a problem. whenever I use the SugarRecord.update() method to update and existing record all records are replaced by the new record.

Could anyone please help me with an answer?

@Override
    public void updateInDataBase(Bookmark bookmark, long id) {
        History oldHistory = History.findById(History.class, id);

        LogManager.d("owntest oldHistory In update  " + oldHistory);
        oldHistory.setLastUpdateTime(System.currentTimeMillis());
        oldHistory.update();
    }

It seems you have found a bug that is described here. https://github.com/chennaione/sugar/issues/633 . It may be the case, that the author intended this for some reason, though I am not sure. Nevertheless, you can and probably should use the save() method as suggested by the official docs: http://satyan.github.io/sugar/getting-started.html#usage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM