author | Ben Turner <bent.mozilla@gmail.com> |
Wed, 13 Apr 2011 00:26:20 -0700 | |
changeset 68042 | 6bcaec19d09ec670366544e0b14c715fada5a657 |
parent 68041 | 5542d52a48328d768b3f2ed4598bd22cb219925f |
child 68043 | 2d69b518b6ab4994b80f532cc9a7c13a0a175890 |
push id | 19485 |
push user | bturner@mozilla.com |
push date | Wed, 13 Apr 2011 07:26:47 +0000 |
treeherder | mozilla-central@6bcaec19d09e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | sdwilsh |
bugs | 638067 |
milestone | 6.0a1 |
first release with | nightly linux32
6bcaec19d09e
/
6.0a1
/
20110413030543
/
files
nightly linux64
6bcaec19d09e
/
6.0a1
/
20110413030543
/
files
nightly mac
6bcaec19d09e
/
6.0a1
/
20110413030543
/
files
nightly win32
6bcaec19d09e
/
6.0a1
/
20110413030543
/
files
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
releases | nightly linux32
6.0a1
/
20110413030543
/
pushlog to previous
nightly linux64
6.0a1
/
20110413030543
/
pushlog to previous
nightly mac
6.0a1
/
20110413030543
/
pushlog to previous
nightly win32
6.0a1
/
20110413030543
/
pushlog to previous
|
--- a/dom/indexedDB/IDBObjectStore.cpp +++ b/dom/indexedDB/IDBObjectStore.cpp @@ -732,28 +732,31 @@ IDBObjectStore::UpdateIndexes(IDBTransac rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("index_id"), updateInfo.info.id); NS_ENSURE_SUCCESS(rv, rv); rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("object_data_id"), aObjectDataId); NS_ENSURE_SUCCESS(rv, rv); - NS_NAMED_LITERAL_CSTRING(objectDataKey, "object_data_key"); - - if (aObjectStoreKey.IsInt()) { - rv = stmt->BindInt64ByName(objectDataKey, aObjectStoreKey.IntValue()); + if (!updateInfo.info.autoIncrement) { + NS_NAMED_LITERAL_CSTRING(objectDataKey, "object_data_key"); + + if (aObjectStoreKey.IsInt()) { + rv = stmt->BindInt64ByName(objectDataKey, aObjectStoreKey.IntValue()); + } + else if (aObjectStoreKey.IsString()) { + rv = stmt->BindStringByName(objectDataKey, + aObjectStoreKey.StringValue()); + } + else { + NS_NOTREACHED("Unknown key type!"); + } + NS_ENSURE_SUCCESS(rv, rv); } - else if (aObjectStoreKey.IsString()) { - rv = stmt->BindStringByName(objectDataKey, aObjectStoreKey.StringValue()); - } - else { - NS_NOTREACHED("Unknown key type!"); - } - NS_ENSURE_SUCCESS(rv, rv); NS_NAMED_LITERAL_CSTRING(value, "value"); if (updateInfo.value.IsInt()) { rv = stmt->BindInt64ByName(value, updateInfo.value.IntValue()); } else if (updateInfo.value.IsString()) { rv = stmt->BindStringByName(value, updateInfo.value.StringValue());
--- a/dom/indexedDB/IDBTransaction.cpp +++ b/dom/indexedDB/IDBTransaction.cpp @@ -474,37 +474,37 @@ IDBTransaction::IndexUpdateStatement(boo bool aUnique, bool aOverwrite) { if (aAutoIncrement) { if (aUnique) { if (aOverwrite) { return GetCachedStatement( "INSERT OR REPLACE INTO ai_unique_index_data " - "(index_id, ai_object_data_id, id, value) " - "VALUES (:index_id, :object_data_id, :object_data_key, :value)" + "(index_id, ai_object_data_id, value) " + "VALUES (:index_id, :object_data_id, :value)" ); } return GetCachedStatement( "INSERT INTO ai_unique_index_data " - "(index_id, aI_object_data_id, id, value) " - "VALUES (:index_id, :object_data_id, :object_data_key, :value)" + "(index_id, aI_object_data_id, value) " + "VALUES (:index_id, :object_data_id, :value)" ); } if (aOverwrite) { return GetCachedStatement( "INSERT OR REPLACE INTO ai_index_data " - "(index_id, ai_object_data_id, id, value) " - "VALUES (:index_id, :object_data_id, :object_data_key, :value)" + "(index_id, ai_object_data_id, value) " + "VALUES (:index_id, :object_data_id, :value)" ); } return GetCachedStatement( "INSERT INTO ai_index_data " - "(index_id, ai_object_data_id, id, value) " - "VALUES (:index_id, :object_data_id, :object_data_key, :value)" + "(index_id, ai_object_data_id, value) " + "VALUES (:index_id, :object_data_id, :value)" ); } if (aUnique) { if (aOverwrite) { return GetCachedStatement( "INSERT OR REPLACE INTO unique_index_data " "(index_id, object_data_id, object_data_key, value) " "VALUES (:index_id, :object_data_id, :object_data_key, :value)"
--- a/dom/indexedDB/test/Makefile.in +++ b/dom/indexedDB/test/Makefile.in @@ -48,16 +48,17 @@ TEST_FILES = \ bfcache_iframe1.html \ bfcache_iframe2.html \ error_events_abort_transactions_iframe.html \ event_propagation_iframe.html \ exceptions_in_success_events_iframe.html \ helpers.js \ leaving_page_iframe.html \ test_add_twice_failure.html \ + test_autoIncrement_indexes.html \ test_bad_keypath.html \ test_bfcache.html \ test_clear.html \ test_create_index.html \ test_create_index_with_integer_keys.html \ test_create_objectStore.html \ test_cursors.html \ test_cursor_mutation.html \
new file mode 100644 --- /dev/null +++ b/dom/indexedDB/test/test_autoIncrement_indexes.html @@ -0,0 +1,71 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<html> +<head> + <title>Indexed Database Property Test</title> + + <script type="text/javascript" src="/MochiKit/packed.js"></script> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + + <script type="text/javascript;version=1.7"> + function testSteps() + { + let request = mozIndexedDB.open(window.location.pathname); + request.onerror = errorHandler; + request.onsuccess = grabEventAndContinueHandler; + let event = yield; + + let db = request.result; + db.onerror = errorHandler; + + db.setVersion("1").onsuccess = grabEventAndContinueHandler; + let event = yield; + + let objectStore = db.createObjectStore("foo", { keyPath: "id", + autoIncrement: true }); + objectStore.createIndex("first","first"); + objectStore.createIndex("second","second"); + objectStore.createIndex("third","third"); + + let data = { first: "foo", second: "foo", third: "foo" }; + + objectStore.add(data).onsuccess = grabEventAndContinueHandler; + event = yield; + + let key = event.target.result; + ok(key, "Added entry"); + + let objectStore = db.transaction("foo").objectStore("foo"); + let first = objectStore.index("first"); + let second = objectStore.index("second"); + let third = objectStore.index("third"); + + first.get("foo").onsuccess = grabEventAndContinueHandler; + event = yield; + + is (event.target.result.id, key, "Entry in first"); + + second.get("foo").onsuccess = grabEventAndContinueHandler; + event = yield; + + is (event.target.result.id, key, "Entry in second"); + + third.get("foo").onsuccess = grabEventAndContinueHandler; + event = yield; + + is (event.target.result.id, key, "Entry in third"); + + finishTest(); + yield; + } + </script> + <script type="text/javascript;version=1.7" src="helpers.js"></script> + +</head> + +<body onload="runTest();"></body> + +</html>