-
-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline keys and autoincrement not working #122
Comments
You are right, it is an issue. There is a workaround though (if I understand the issue correctly). Note: You are right, this definitely needs to be fixed. |
I'd run into the same issue today. I changed the .add logic to include the autogenerated key into the record:
|
Thanks a lot @IntranetFactory. Why not submitting that patch as a PR? Would that be ok @DickvdBrink? |
Yeah I think so, I can't really see the difference with the above patch but I will definitely take a look at it when submitted as a PR! |
The patch stores the auto generated key value inline in the records in the property defined by keyPath. I'm sorry, but I've no idea how to make a PR. |
Hi @IntranetFactory, I am having some problems interpreting the diff code too. Creating a Pull Request is very easy:
The difficult part was fixing this. Creating a PR is really easy :), so let me know if you need further help. |
I updated IndexedDBShim.min.js and db.js to the latest version as of December 23, 2014. But still get the error with keys in my Phonegap app at Android emulator (in desktop browser Firefox 34 there is no such problem). Example: |
This issue has been fixed in the latest version. Give it a try and let us know if you find any other issues. Thanks! |
Now the problem is gone (application is work). But the object in emulator (Android) was to look like this: [{"units":"Metric","language":"English","id":0,"undefined":0}] instead of [{"units":"Metric","language":"English","id":0}] |
Just to clarify... are you saying that |
I made some experiments and found that the problem occurs not always. For example this code (it is initialization of app) return additional "undefined" after "id": server.settings.query()
.all()
.execute()
.then(function(results) {
if(results.length) {
// some init operations
} else {
// need to add default settings to DB
server.settings.add({
'units': 'metric',
'language': 'english'
}).then(function(item) {
// all done
console.log(JSON.stringify(item));
});
}
}); Output is: "[{"units":"metric","language":"english","id":1,"undefined":1}]" |
Can you post a code sample using the raw IndexedDB api instead of IDBWrapper? That'll make it much easier to figure out what's causing the problem. |
I made some new experiments with new indexeddbshim.js and it's working fine. Thanks! |
Awesome! Great to hear. |
Hi,
I am experiencing this issue.
When using inline keys with autoincrement, the generated key is not stored with the data. When you read them from the database, there is no reference to its original key, so you can't make updates.
This problem doesn't happen with the facebook polyfill.
I think this issue is pretty serious, as it impacts a very common usage pattern.
Regards
The text was updated successfully, but these errors were encountered: