PDA

View Full Version : [FIXED-264] Ext.data.WebStorageProxy.getNextId() generating string ids



yuki
8 Sep 2010, 5:36 PM
Sencha Touch version tested:

0.94


Description:

Ids generated in "strings" not in "int" as expexted, e.g. ids will be 1,11,111,... instead of 1,2,3,...


Possible fix:

getNextId: function() {
var obj = this.getStorageObject(),
key = this.getRecordCounterKey(),
last = obj[key],
ids, id;

if (last == undefined) {
ids = this.getIds();
last = parseInt(ids[ids.length - 1], 10) || 0;
}

id = parseInt(last) + 1; // parseInt before adding 1 ("last" is always string)
obj.setItem(key, id);

return id;
}

Jamie Avins
9 Sep 2010, 9:21 AM
Thanks Yuki, don't forget your radix ;)