Changeset 76126 in webkit
- Timestamp:
- Jan 19, 2011 8:24:05 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r76125 r76126 1 2011-01-19 Hans Wennborg <hans@chromium.org> 2 3 Reviewed by Jeremy Orlow. 4 5 IndexedDB: Support auto-increment keys 6 https://bugs.webkit.org/show_bug.cgi?id=52576 7 8 Add layout test for auto increment keys. 9 Update previous test not to consider auto increment an error. 10 11 * storage/indexeddb/create-object-store-options-expected.txt: 12 * storage/indexeddb/create-object-store-options.html: 13 * storage/indexeddb/objectstore-autoincrement-expected.txt: Added. 14 * storage/indexeddb/objectstore-autoincrement.html: Added. 15 1 16 2011-01-19 Csaba Osztrogonác <ossy@webkit.org> 2 17 -
trunk/LayoutTests/storage/indexeddb/create-object-store-options-expected.txt
r72765 r76126 18 18 db.createObjectStore('b') 19 19 db.createObjectStore('c', {autoIncrement: true}); 20 PASS Exception thrown21 PASS code is webkitIDBDatabaseException.UNKNOWN_ERR22 20 trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE}) 23 21 PASS trans.mode is webkitIDBTransaction.READ_WRITE -
trunk/LayoutTests/storage/indexeddb/create-object-store-options.html
r72765 r76126 45 45 evalAndLog("db.createObjectStore('b')"); 46 46 47 try { 48 // FIXME: This should work in the future. 49 debug("db.createObjectStore('c', {autoIncrement: true});"); 50 db.createObjectStore('c', {autoIncrement: true}); 51 testFailed('createObjectStore with autoIncrement = true should throw'); 52 } catch (err) { 53 testPassed("Exception thrown"); 54 code = err.code; 55 shouldBe("code", "webkitIDBDatabaseException.UNKNOWN_ERR"); 56 } 47 debug("db.createObjectStore('c', {autoIncrement: true});"); 48 db.createObjectStore('c', {autoIncrement: true}); 57 49 58 50 trans = evalAndLog("trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE})"); -
trunk/Source/WebCore/ChangeLog
r76122 r76126 1 2011-01-19 Hans Wennborg <hans@chromium.org> 2 3 Reviewed by Jeremy Orlow. 4 5 IndexedDB: Support auto-increment keys 6 https://bugs.webkit.org/show_bug.cgi?id=52576 7 8 Add support for auto-increment keys. 9 10 Test: storage/indexeddb/objectstore-autoincrement.html 11 12 * storage/IDBDatabase.cpp: 13 (WebCore::IDBDatabase::createObjectStore): 14 * storage/IDBObjectStoreBackendImpl.cpp: 15 (WebCore::genAutoIncrementKey): 16 (WebCore::IDBObjectStoreBackendImpl::putInternal): 17 1 18 2011-01-19 Csaba Osztrogonác <ossy@webkit.org> 2 19 -
trunk/Source/WebCore/storage/IDBDatabase.cpp
r72771 r76126 74 74 // FIXME: Look up evictable and pass that on as well. 75 75 76 if (autoIncrement) {77 // FIXME: Implement support for auto increment.78 ec = IDBDatabaseException::UNKNOWN_ERR;79 return 0;80 }81 82 76 RefPtr<IDBObjectStoreBackendInterface> objectStore = m_backend->createObjectStore(name, keyPath, autoIncrement, m_setVersionTransaction.get(), ec); 83 77 if (!objectStore) { -
trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp
r75596 r76126 60 60 , m_keyPath(keyPath) 61 61 , m_autoIncrement(autoIncrement) 62 , m_autoIncrementNumber(-1) 62 63 { 63 64 loadIndexes(); … … 70 71 , m_keyPath(keyPath) 71 72 , m_autoIncrement(autoIncrement) 73 , m_autoIncrementNumber(-1) 72 74 { 73 75 } … … 114 116 115 117 ASSERT((key->type() == IDBKey::StringType) != query.isColumnNull(0)); 116 // FIXME: Implement date.118 ASSERT((key->type() == IDBKey::DateType) != query.isColumnNull(1)); 117 119 ASSERT((key->type() == IDBKey::NumberType) != query.isColumnNull(2)); 118 120 … … 201 203 RefPtr<IDBKey> key = prpKey; 202 204 203 // FIXME: Support auto-increment. 204 205 if (!objectStore->m_keyPath.isNull()) { 206 if (key) { 207 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "A key was supplied for an objectStore that has a keyPath.")); 205 if (!objectStore->m_keyPath.isNull() && key) { 206 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "A key was supplied for an objectStore that has a keyPath.")); 207 return; 208 } 209 210 if (objectStore->autoIncrement() && key) { 211 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "A key was supplied for an objectStore that is using auto increment.")); 212 return; 213 } 214 215 if (objectStore->autoIncrement()) { 216 key = objectStore->genAutoIncrementKey(); 217 218 if (!objectStore->m_keyPath.isNull()) { 219 // FIXME: Inject the generated key into the object. 220 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Adding data to object stores with auto increment and in-line keys not yet supported.")); 208 221 return; 209 222 } 223 } else if (!objectStore->m_keyPath.isNull()) { 210 224 key = fetchKeyFromKeyPath(value.get(), objectStore->m_keyPath); 225 211 226 if (!key) { 212 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException:: UNKNOWN_ERR, "The key could not be fetched from the keyPath."));227 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "The key could not be fetched from the keyPath.")); 213 228 return; 214 229 } … … 217 232 return; 218 233 } 234 219 235 if (key->type() == IDBKey::NullType) { 220 236 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "NULL key is not allowed.")); … … 512 528 } 513 529 530 PassRefPtr<IDBKey> IDBObjectStoreBackendImpl::genAutoIncrementKey() 531 { 532 if (m_autoIncrementNumber > 0) 533 return IDBKey::createNumber(m_autoIncrementNumber++); 534 535 String sql = "SELECT max(keyNumber) + 1 FROM ObjectStoreData WHERE objectStoreId = ? AND keyString IS NULL AND keyDate IS NULL"; 536 537 SQLiteStatement query(sqliteDatabase(), sql); 538 bool ok = query.prepare() == SQLResultOk; 539 ASSERT_UNUSED(ok, ok); 540 541 query.bindInt64(1, id()); 542 543 if (query.step() != SQLResultRow || query.isColumnNull(0)) 544 m_autoIncrementNumber = 1; 545 else 546 m_autoIncrementNumber = static_cast<int>(query.getColumnDouble(0)); 547 548 return IDBKey::createNumber(m_autoIncrementNumber++); 549 } 550 514 551 515 552 } // namespace WebCore -
trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.h
r72771 r76126 83 83 void loadIndexes(); 84 84 SQLiteDatabase& sqliteDatabase() const; 85 PassRefPtr<IDBKey> genAutoIncrementKey(); 85 86 86 87 static void getInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks>); … … 104 105 typedef HashMap<String, RefPtr<IDBIndexBackendImpl> > IndexMap; 105 106 IndexMap m_indexes; 107 int m_autoIncrementNumber; 106 108 }; 107 109
Note: See TracChangeset
for help on using the changeset viewer.