Closed
Bug 715963
Opened 14 years ago
Closed 11 years ago
IndexedDB: Cannot create ObjectStores
Categories
(Core :: Storage: IndexedDB, defect)
Tracking
()
RESOLVED
INCOMPLETE
People
(Reporter: lcid-fire, Unassigned)
Details
Attachments
(1 file)
|
2.14 KB,
text/plain
|
Details |
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.8 (KHTML, like Gecko) Ubuntu/11.10 Chromium/17.0.942.0 Chrome/17.0.942.0 Safari/535.8
Steps to reproduce:
On a site with url "localhost:8080/test.html"
var request = indexedDB.open("_test_", 1);
request.onsuccess = function() {
var os = request.result.createObjectStore("somestore");
};
Actual results:
When it executes createObject I get the exception with the dumb message: "A mutation operation was attempted on a database that did not allow mutations".
This isn't helpfull at all.
Expected results:
It should have created the object store.
Even when I move the createObjectStore call to onupgradeneeded , it still does not work since it never calls onupgradeneeded.
Comment 2•14 years ago
|
||
IMHO it's not a bug. See attached test case.
Comment 3•14 years ago
|
||
Hi !
"onupgradeneeded" is called only the first time the database is opened, or when the database version has changed.
You may have to delete the database before testing again, or change the database version to trigger another "onupgradeneeded" call.
See attached example page (https://bugzilla.mozilla.org/attachment.cgi?id=604395), or following code :
// indexedDB = window.indexedDB || window.mozIndexedDB
//
// either delete database first
indexedDB.deleteDatabase("_test_");
//
// or change database version
request = indexedDB.open("_test_", 2);
// then execute that test function:
var testDB = function () {
var request = indexedDB.open("_test_"),
connectionToDB; // var to keep the opened connection to the database
request.onupgradeneeded = function () {
log("onupgradeneed: creating somestore");
request.result.createObjectStore("somestore");
};
request.onsuccess = function (e) {
connectionToDB = request.result;
log("onsuccess: somestore exists ? => " + connectionToDB.objectStoreNames.contains("somestore")); // => true
// close connection when not needed anymore
connectionToDB.close();
};
request.onerror = function (e) {
log('onerror: opening _test_ failed with e.target.errorCode = ' + e.target.errorCode);
};
};
testDB();
Also, I recommend you have a look at https://developer.mozilla.org/en/IndexedDB/Using_IndexedDB .
Unfortunately, there are very few good examples of indexedDB usage out there...
I hope that helps !
Comment 4•14 years ago
|
||
Icid-fire, can you please test again and confirm the issue is resolved ?
Thanks.
Component: Untriaged → DOM: IndexedDB
Product: Firefox → Core
Version: 10 Branch → unspecified
Updated•14 years ago
|
QA Contact: untriaged → indexeddb
I answered your question in bug 736948. Please don't post on multiple bugs.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → INCOMPLETE
comment 5 was linkspam
You need to log in
before you can comment on or make changes to this bug.
Description
•