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

Firefox compatibility, IndexedDB fixes; batch remove fixes; issue #108. #130

Merged
merged 18 commits into from
Oct 17, 2012

Conversation

cscott
Copy link
Contributor

@cscott cscott commented Oct 17, 2012

I can split this patch set into four pieces if you like. But you've been pulling my patches promptly so I thought I'd combine the pull requests. There are four things here:

  1. First three patches in the set fix firefox compatibility issues with the test suite.

  2. The remainder of the patches in the first batch fix the IndexedDB adapter and make it work on latest Chrome and latest Firefox. These patches should resolve Updated IndexedDB Adapter #120 (I reviewed Paul Lewis' patch and incorporated his non-whitespace fixes), and hopefully indexed-db adaptor 0.6.30 not working on Firefox 12 #103, Firefox and indexed-db adapter #126 and Uncaught Error: InvalidStateError: DOM IDBDatabase Exception 11 indexed-db.js:105 #127 as well (at least the test suite works!).

  3. The third set of patches (from 023826f on) adds a test case for batch add/get/remove to the test suite. Then the patches go and fix all the bugs in the dom, webkit-sqlite, and indexeddb adapters which were uncovered by the new test case. This should resolve websql.lite adapter - SQL escaping error on get #118, webkit-sqlite changes to use parameters for the IDs on get #119, and "remove" method parameters change according to active adapter #94.

  4. The final patch resolves window-name adapter nuke function #108 and fixes the "independent data store" failure in the test suite for the memory and window-name adapters.

Doesn't actually make this adapter work on Firefox, but at least keeps it
from crashing the test suite.
…t suite.

This makes the new 'click to test an adapter' functionality work on Firefox.
Firefox's IndexedDB implementation is significantly slower than webkit's,
which causes sporadic failures of the test suite.
…eak.

This prevents a leak in Chrome.  Granted, this is actually a bug in chrome:
the request objects should get garbage collected which should also free up
the event listeners.  But this doesn't appear to be happening (as shown
in Chrome's memory tracing tools).
Numeric constants for transaction mode are deprecated.
Spec says that cursor is null if the range is empty, but firefox makes the
cursor undefined instead.
…refox).

Transaction creation inside a versionchange transaction is disallowed.
…Increment.

Both Firefox and Webkit have issues with the autoIncrement feature of
IndexedDB.  Let's assume that those bugs will be fixed by the time the
spec becomes final and indexedDB is unprefixed -- but until that time,
don't use the feature and use the same this.uuid() key-generator that the
other implementations use.
The previous implementations suffered from race conditions: the order of
the results was not guaranteed to match the order given in the parameters.
The webkit-sqlite, indexed-db, and dom adapters all fail this new test in
various ways.
Implement batch remove.  While we're at it, make the "is this a key or
an object containing a key" test consistent with that used in the other
adapters.
Passing an array to get() could previously return a result array shorter
than the parameter array, since keys not present in the lawnchair were missing
from the result.  Add 'null' in the place of the missing result, to be
consistent with other adapters.

Implement batch remove (using code borrowed from the indexedDB adapter).
Update the batch() implementation to match that used in the other
adapters.  Removes the need for setInterval() to poll for completion.

Fix sql quoting issues in get() implementation, and ensure that the
order of returned results matches the order of the keys provided as
arguments in the batch get case.

Implement batch remove.  Update the "is this a key or an object containing
a key" test to match that used in the other adapters.
…ers.

Also fixes issue brianleroux#108 with the nuke() method, while we're at it.

In addition, a few minor changes to try to make memory and window-name more
nearly identical, although a number of unnecessary whitespace diffs remain.
brianleroux added a commit that referenced this pull request Oct 17, 2012
Firefox compatibility, IndexedDB fixes; batch remove fixes; issue #108.
@brianleroux brianleroux merged commit 94cc0c6 into brianleroux:master Oct 17, 2012
@brianleroux
Copy link
Owner

this is great---don't worry about the formatting. have some conference-driven-development coming up for this so I'll do the tidy =)

@cscott
Copy link
Contributor Author

cscott commented Oct 17, 2012

Incidentally, one thing I noticed was that a lot of adapters share basically the same implementation of batch set/get/remove. It might be worth providing a default implementation in Lawnchair.prototype and then doing something like:

  get: function(keyOrArray) {
     if (this.isArray(keyOrArray)) {
         return Lawnchair.prototype.get.call(this, keyOrArray);
     }
     /* ... rest of single-key implementation here ... */
  }

Similarly for remove. And any adapter which doesn't have an efficient batch put could just not override batch and use a default implementation of batch() from Lawnchair.prototype.

Might be a worthwhile refactoring for your conference-driven-development. ;-)

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.

window-name adapter nuke function websql.lite adapter - SQL escaping error on get
2 participants