Title: [92951] trunk
Revision
92951
Author
[email protected]
Date
2011-08-12 02:32:32 -0700 (Fri, 12 Aug 2011)

Log Message

IndexedDB: Object store records don't need to have keys in all indexes
https://bugs.webkit.org/show_bug.cgi?id=66049

Reviewed by Tony Chang.

Source/WebCore:

Allow inserting records in an object store even though they don't
yield keys in some index. The spec has changed in this regard.

* storage/IDBObjectStoreBackendImpl.cpp:
(WebCore::IDBObjectStoreBackendImpl::putInternal):

LayoutTests:

Update test to make sure it's possible to add an object store record
even though it doesn't yield keys in every index.

* storage/indexeddb/index-basics-expected.txt:
* storage/indexeddb/index-basics.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (92950 => 92951)


--- trunk/LayoutTests/ChangeLog	2011-08-12 08:51:14 UTC (rev 92950)
+++ trunk/LayoutTests/ChangeLog	2011-08-12 09:32:32 UTC (rev 92951)
@@ -1,3 +1,16 @@
+2011-08-11  Hans Wennborg  <[email protected]>
+
+        IndexedDB: Object store records don't need to have keys in all indexes
+        https://bugs.webkit.org/show_bug.cgi?id=66049
+
+        Reviewed by Tony Chang.
+
+        Update test to make sure it's possible to add an object store record
+        even though it doesn't yield keys in every index.
+
+        * storage/indexeddb/index-basics-expected.txt:
+        * storage/indexeddb/index-basics.html:
+
 2011-08-10  Hans Wennborg  <[email protected]>
 
         IndexedDB: Overwriting key in unique index should be possible

Modified: trunk/LayoutTests/storage/indexeddb/index-basics-expected.txt (92950 => 92951)


--- trunk/LayoutTests/storage/indexeddb/index-basics-expected.txt	2011-08-12 08:51:14 UTC (rev 92950)
+++ trunk/LayoutTests/storage/indexeddb/index-basics-expected.txt	2011-08-12 09:32:32 UTC (rev 92951)
@@ -30,6 +30,7 @@
 event.target.source.add({x: 'value2', y: 'zzz2', z: 2.71, foobar: 12}, 'key2')
 store.createIndex('indexWhileAddIsInFlight', 'x')
 store.createIndex('indexWithWeirdKeyPath', 'foobar')
+event.target.source.add({x: 'value3', y: '456'}, 'key3')
 indexObject.getKey('value')
 PASS event.target.result is "key"
 indexObject2.getKey('zzz')
@@ -57,6 +58,10 @@
 PASS event.target.result.key is "value2"
 PASS event.target.result.primaryKey is "key2"
 event.target.result.continue()
+PASS event.target.result === null is false
+PASS event.target.result.key is "value3"
+PASS event.target.result.primaryKey is "key3"
+event.target.result.continue()
 PASS event.target.result === null is true
 indexObject.openCursor()
 PASS event.target.source is indexObject
@@ -70,6 +75,11 @@
 PASS event.target.result.value.x is "value2"
 PASS event.target.result.value.y is "zzz2"
 event.target.result.continue()
+PASS event.target.result === null is false
+PASS event.target.result.key is "value3"
+PASS event.target.result.value.x is "value3"
+PASS event.target.result.value.y is "456"
+event.target.result.continue()
 PASS event.target.result === null is true
 Passing an invalid key into indexObject.get().
 PASS Caught exception: Error: TYPE_MISMATCH_ERR: DOM Exception 17

Modified: trunk/LayoutTests/storage/indexeddb/index-basics.html (92950 => 92951)


--- trunk/LayoutTests/storage/indexeddb/index-basics.html	2011-08-12 08:51:14 UTC (rev 92950)
+++ trunk/LayoutTests/storage/indexeddb/index-basics.html	2011-08-12 09:32:32 UTC (rev 92951)
@@ -62,19 +62,27 @@
     shouldBeTrue("'get' in indexObject");
 
     request = evalAndLog("store.add({x: 'value', y: 'zzz', z: 2.72}, 'key')");
-    request._onsuccess_ = addMore;
+    request._onsuccess_ = addData2;
     request._onerror_ = unexpectedErrorCallback;
 }
 
-function addMore()
+function addData2()
 {
     request = evalAndLog("event.target.source.add({x: 'value2', y: 'zzz2', z: 2.71, foobar: 12}, 'key2')");
-    request._onsuccess_ = getData;
+    request._onsuccess_ = addData3;
     request._onerror_ = unexpectedErrorCallback;
     window.indexObject4 = evalAndLog("store.createIndex('indexWhileAddIsInFlight', 'x')");
     window.indexObject5 = evalAndLog("store.createIndex('indexWithWeirdKeyPath', 'foobar')");
 }
 
+function addData3()
+{
+    // Add data which doesn't have a key in the zIndex.
+    request = evalAndLog("event.target.source.add({x: 'value3', y: '456'}, 'key3')");
+    request._onsuccess_ = getData;
+    request._onerror_ = unexpectedErrorCallback;
+}
+
 function getData()
 {
     request = evalAndLog("indexObject.getKey('value')");
@@ -169,6 +177,17 @@
 
     // We re-use the last request object.
     evalAndLog("event.target.result.continue()");
+    window.request._onsuccess_ = cursor1Continue3;
+}
+
+function cursor1Continue3()
+{
+    shouldBeFalse("event.target.result === null");
+    shouldBeEqualToString("event.target.result.key", "value3");
+    shouldBeEqualToString("event.target.result.primaryKey", "key3");
+
+    // We re-use the last request object.
+    evalAndLog("event.target.result.continue()");
     window.request._onsuccess_ = openObjectCursor;
 }
 
@@ -198,11 +217,23 @@
 {
     shouldBeFalse("event.target.result === null");
     shouldBeEqualToString("event.target.result.key", "value2");
-    shouldBeEqualToString("event.target.result.value.x", "value2");    
+    shouldBeEqualToString("event.target.result.value.x", "value2");
     shouldBeEqualToString("event.target.result.value.y", "zzz2");
 
     // We re-use the last request object.
     evalAndLog("event.target.result.continue()");
+    window.request._onsuccess_ = cursor2Continue3;
+}
+
+function cursor2Continue3()
+{
+    shouldBeFalse("event.target.result === null");
+    shouldBeEqualToString("event.target.result.key", "value3");
+    shouldBeEqualToString("event.target.result.value.x", "value3");
+    shouldBeEqualToString("event.target.result.value.y", "456");
+
+    // We re-use the last request object.
+    evalAndLog("event.target.result.continue()");
     window.request._onsuccess_ = last;
 }
 

Modified: trunk/Source/WebCore/ChangeLog (92950 => 92951)


--- trunk/Source/WebCore/ChangeLog	2011-08-12 08:51:14 UTC (rev 92950)
+++ trunk/Source/WebCore/ChangeLog	2011-08-12 09:32:32 UTC (rev 92951)
@@ -1,3 +1,16 @@
+2011-08-11  Hans Wennborg  <[email protected]>
+
+        IndexedDB: Object store records don't need to have keys in all indexes
+        https://bugs.webkit.org/show_bug.cgi?id=66049
+
+        Reviewed by Tony Chang.
+
+        Allow inserting records in an object store even though they don't
+        yield keys in some index. The spec has changed in this regard.
+
+        * storage/IDBObjectStoreBackendImpl.cpp:
+        (WebCore::IDBObjectStoreBackendImpl::putInternal):
+
 2011-08-10  Hans Wennborg  <[email protected]>
 
         IndexedDB: Overwriting key in unique index should be possible

Modified: trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp (92950 => 92951)


--- trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp	2011-08-12 08:51:14 UTC (rev 92950)
+++ trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp	2011-08-12 09:32:32 UTC (rev 92951)
@@ -230,8 +230,8 @@
 
         RefPtr<IDBKey> indexKey = fetchKeyFromKeyPath(value.get(), index->keyPath());
         if (!indexKey) {
-            callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "The key could not be fetched from an index's keyPath."));
-            return;
+            indexKeys.append(indexKey.release());
+            continue;
         }
         if (indexKey->type() == IDBKey::NullType) {
             callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "One of the derived (from a keyPath) keys for an index is NULL."));
@@ -273,6 +273,8 @@
             return;
         }
 
+        if (!indexKeys[i])
+            continue;
         if (!objectStore->m_backingStore->putIndexDataForRecord(objectStore->m_databaseId, objectStore->id(), it->second->id(), *indexKeys[i], recordIdentifier.get())) {
             // FIXME: The Indexed Database specification does not have an error code dedicated to I/O errors.
             callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage."));
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to