Skip to content
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

Fresh version schema #20

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

brettz9
Copy link
Contributor

@brettz9 brettz9 commented May 3, 2016

This builds on top of the previous PRs with a single commit to:

  • Feature: Support a setCurrentVersion method and use it upon each (upgradeneeded) callback iteration (so they can operate on their version);
  • Fix: Iterate over versions rather than objects (to ensure not working on a stale object)

I've tried to rebase all of the previous PRs to incorporate fixes, but I hope you can accept this fix without me rebasing all of the other PRs, as this one would be time-consuming and error-prone to incorporate backwards.

FYI, I am ready with my idb-import project for JSON-based imports (at least a functional first version of it). Let me know if you would like it under treojs. I'm eager to start on adding that repo, so, assuming you wanted to house it, I'd appreciate it if you could set that up even before reviewing these PRs.

…allow a sequence of upgrades which can support promises returned by `addCallback` callbacks (and add docs and tests for multiple promise-based callbacks on different versions);

Commenting: Indicate specific Safari bug within code;
Refactoring: Use ES6 `Array.from`; add `Number.isInteger` and ES7 `Object.values()` in place of npm modules (requires babel-polyfill);
Testing: Split off local testing from Sauce; prevent blocking; increase timeout for Firefox; add test to throw with previous version
…ted `addCallback` ones, can themselves use idb-schema methods (e.g., to convert from JSON to idb-schema) though, since they execute within `upgradeneeded` cannot support Promises (as can the callbacks within `addCallback` when `schema.open` or `schema.upgrade` are used); document
… added previously)

- If `delStore` does throw later (or if there is any other upgrade error), the error can be caught by `callback` or `open`/`upgrade`
- Feature: Support `errBack` to `callback`
- Expand callback, delStore docs
… at run-time);

Fix: Allow stores and indexes to be an empty string;
Fix: allow empty-string key path (unless with autoIncrement);
Fix: disallow autoIncrement with array keyPath but enable for non-empty strings (as permitted by spec--keys overridable on put()/add())
Testing: Add tests for above
…n so that one can delete old stores or indexes and recreate them if desired (add tests);

- Refactoring: Put schema.open/schema.upgrade tests in own "describe" section
… order,

  but the getter will continue to get the highest version. To get the current
  rather than highest version, the method `lastEnteredVersion()` has been
  added.
- Refactoring: better default behavior for getJSONStorage internal method
…eeded) callback iteration (so they can operate on their version);

- Iterate over versions rather than objects (to ensure not working on a stale object)
- Update babel-polyfill version
@brettz9
Copy link
Contributor Author

brettz9 commented Jun 6, 2016

Hi--when do you think you might get to taking a look at these PRs (as well as the PRs for idb-batch and idb-factory)?

@alekseykulikov
Copy link
Contributor

Hey Brett,
Thank you for all your great job!
I'm really sorry for postponing this PRs. May was a crazy month... I feel quite bad about myself and really appreciate your effort! I will try to find the time on this week. If you wish we could have a quick Skype call, my account is alekseys.kulikov and I'm in CEST timezone.

@brettz9
Copy link
Contributor Author

brettz9 commented Jun 6, 2016

Hi Aleksey,

No worries, you've saved me a lot of time with such excellent work. I'm particularly intrigued now by idb-polyfill which I had not really taken a good look at before (interestingly, I have just been refactoring IndexedDBShim to use ES6 modules as I see you did a while ago with idb-polyfill--maybe I'll finish my PR with it and see how it compares to idb-polyfill.)

@alekseykulikov
Copy link
Contributor

alekseykulikov commented Jun 7, 2016

Thank you Brett for good words!
I wanted to make idb-polyfill as ultimate IndexedDB polyfill, which can use memory/localStorage/websql or even fix IndexedDB in Safari. But it became too ambitious project and now I'm so limited with time... someday I will have more time... or maybe we could collaborate on it together :)

@brettz9
Copy link
Contributor Author

brettz9 commented Jun 13, 2016

My main interest now is websql and since the project is well under way already with IndexedDBShim, I am currently working on that under my own branch, having imported all of your tests and made the few modifications needed to get it to work (For your various errors, e.g., InactiveStateError, I've replaced checks of these with simple checks of DOMException since those are the actual instances being expected (though I should add checks for the name property).

I've noticed some issues in the tests which I've been fixing along the way, but I'm afraid it may be too time-consuming for me to return the changes to you. You're of course welcome to track them or if you prefer, join us on IndexedDBShim and then abstract out the SQL for the assorted environments (and the owner has graciously given me commit access, so I hope to be able to work at a quick pace).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants