Issue with integer keys causing data duplication
mdlawson opened this issue · 3 comments
If depot's idAttribute
is set to a key that contains integers, there is a data duplication bug that occurs on update. When save is called during the update, this.ids.indexOf([integer])
will always return -1 because this.ids
is an array of strings, causing save to behave as if it was inserting a new record.
I am fairly sure this is not the correct behavior. The simplest and probably fastest fix is to simply do this.ids.indexOf(""+id)
and this.ids.push(""+id)
which should work properly in all cases.
@mdlawson good catch. I think I was able to reproduce it. I changed save
function: https://github.com/mkuklis/depot.js/blob/master/depot.js#L30 in order to fix it. Please let me know if this fix works for you.
Working fine here, thanks for the quick patch!