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

IndexedDB should handle version change differences #2603

Closed
sethladd opened this issue Apr 17, 2012 · 9 comments
Closed

IndexedDB should handle version change differences #2603

sethladd opened this issue Apr 17, 2012 · 9 comments
Assignees
Labels
closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug web-libraries Issues impacting dart:html, etc., libraries
Milestone

Comments

@sethladd
Copy link
Contributor

Chrome supports the old setVersion call, Firefox (and IE 10) support the new onversionchange callback. Our IndexedDB HTML lib should mask the differences, or at least allow us to manually handle both scenarios. This ensures the app runs on both Firefox and Chrome.

Here's the basic JavaScript code to handle both:

    if (db.setVersion && VERSION != db.version) {
      self.initWebkit(e);
    } else {
      self.init(e);
    }

idb.init = function(e) {
  this.db = e.target.result;
  this.db.onerror = onError;
  if (!this.db.objectStoreNames.contains(IMAGES_STORE)) {
    var store = this.db.createObjectStore(IMAGES_STORE, {keyPath: 'id', autoIncrement: true});
  }
};

idb.initWebkit = function(e) {
  this.db = e.target.result;
  this.db.onerror = onError;

  // Older implementations (Chrome) require creating object stores in setVersion().
  if (VERSION != this.db.version) {
    //var versionRequest = self.db.setVersion(VERSION);
    //versionRequest.onfailure = onError;
    var self = this;
    self.db.setVersion(VERSION).onsuccess = function(e) {
      /if (self.db.objectStoreNames.contains(IMAGES_STORE) {
        db.deleteObjectStore("todo");
      }
/
      if (!self.db.objectStoreNames.contains(IMAGES_STORE)) {
        var store = self.db.createObjectStore(IMAGES_STORE, {keyPath: 'id', autoIncrement: true});
      }
      self.getAllImages();
    };
  } else {
    self.getAllImages();
  }
};

@rakudrama
Copy link
Member

The code sample above does not actually use onversionchange.
Do you have working code that does?

@sethladd
Copy link
Contributor Author

@rakudrama
Copy link
Member

Marked this as blocking #1310.

@vsmenon
Copy link
Member

vsmenon commented Jul 16, 2012

Added this to the M1 milestone.

@iposva-google
Copy link
Contributor

Removed Area-DOM label.
Added Area-HTML label.

@rakudrama
Copy link
Member

Chrome 24 will support the standard 'upgradeNeeded' protocol.
setVersion is deprecated.

It is possible, if a little awkward, to write code in Dart that runs for both.
See https://chromiumcodereview.appspot.com/11052023/ for how the html tests were updated.
I slightly prefer the pattern in indexeddb_3_test.

I'd like to close this as 'WontFix' since Chrome 24 is on the Dev channel and can be expected to reach the stable channel in the usual Chrome release cycle.


cc @sethladd.
Set owner to @rakudrama.

@rakudrama
Copy link
Member

Added WontFix label.

@rakudrama
Copy link
Member

Issue #6446 has been merged into this issue.

@sethladd
Copy link
Contributor Author

sethladd commented Nov 1, 2012

@sethladd sethladd added Type-Enhancement web-libraries Issues impacting dart:html, etc., libraries labels Nov 1, 2012
@sethladd sethladd added this to the M1 milestone Nov 1, 2012
@kevmoo kevmoo added closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug and removed resolution-wont_fix labels Mar 1, 2016
dart-bot pushed a commit that referenced this issue Aug 11, 2020
> git log --oneline 04b054b62cc437cf23451785fdc50e49cd9de139..master
0d185a39 (HEAD -> master, origin/master, origin/HEAD) Push null-safety forwards to 2.11 (#2604)
56f9f27f Hide outdated --mode flag (#2603)
61ce6f81 Avoid double loop (#2605)
fa6e57d7 (disable_mixed_mode_validation) Fix outdated latest ordering (#2598)
6549e4aa Remove unused dependency from pubspec.yaml (#2592)
61543d07 Don't look for external package foo during testing (#2599)
590b448f Fixed license headers (#2595)
04e0601e Don't show entries for dev-dependencies in outdated --json --no-dev-dependencies (#2591)
8c3778c4 Configure GitHub move app (#2578)
eec7beca (top_level_command) Pass --(no-)sound-null-safety arg through to VM. (#2542)
152e4740 Warn about publishing in mixed mode (#2583)
0b7a3abe Removed april fools toys (#2325)
b74a5b73 Actually print hints (#2582)
8ec3a66d (pub2) Fix outdated --no-color (#2572)
7bb3d4e6 Use getSdkPath() in NullSafetyAnalysis (#2573)
3c578f24 Drop the "magic" package concept (#2577)
0e967ff0 Remove unused function (#2570)
988fefef Remove dependency overrides (#2568)

Change-Id: I58bf14234ed55bf9d825de60a40ded1d65281195
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158003
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug web-libraries Issues impacting dart:html, etc., libraries
Projects
None yet
Development

No branches or pull requests

5 participants