chennaione / sugar

Insanely easy way to work with Android Database.
http://satyan.github.com/sugar/
MIT License
2.62k stars 583 forks source link

inconsistent behavior when override equals method #718

Open yohaybn opened 7 years ago

yohaybn commented 7 years ago

Hi. when override equals method I get inconsistent behavior when I try to call to listAll(class), I get 0-5 rows where I have 120 rows in the DB.

MatthewTrout commented 7 years ago

Seconded. I cannot use hashcode & equals to check equality on type + id. If I do, I get queer behaviour when saving, I believe due to the cache of object references that seems to exist in sugar. It manifests itself when saving entity A, with related entity B as a field, when retrieving from the database after saving, the entity A has a null value for B and indeed checking the database - it never saved it. This is a pain because these entities support the view, where various data-structures are using the equals method to infer equality, and I can't make that behaviour semantic to my application domain.