Bug 101189 - [JSC] IndexedDB: Can't create object store with null keyPath
Summary: [JSC] IndexedDB: Can't create object store with null keyPath
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-05 00:36 PST by Long Xiang
Modified: 2022-02-01 13:54 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Long Xiang 2012-11-05 00:36:00 PST
running below JavaScript code in set version onsuccess callback:
    db.createObjectStore(objectStoreName, {keyPath: null});
will trigger IDB_SYNTAX_ERR exception other than successfully create an object store with out-of-line keys.
Refer to http://www.w3.org/TR/2011/WD-IndexedDB-20111206/#widl-IDBDatabase-createObjectStore-IDBObjectStore-DOMString-name-IDBObjectStoreParameters-optionalParameters 

in WebCore::IDBDatabase::createObjectStore function:
...
Vector<String> keyPathArray;
if (options.get("keyPath", keyPathArray))
    keyPath = IDBKeyPath(keyPathArray);
...
The options.get() will successfully return true with an empty vector other than return false.

in WebCore::JSDictionary::tryGetPropertyAndResult function:

    case PropertyFound: {
        Result result;
        convertValue(m_exec, value, result);
...
convertValue will return normally when the value is undefined or null, and improperly set the empty result to context.
Chromium with V8 binding doesn't have this issue.
Comment 1 Sihui Liu 2022-02-01 13:54:37 PST
Close this as this is fixed in latest Safari on macOS Monterey 12.3 beta. Tested with following code and no error:

var request = indexedDB.open('test'); 
request.onupgradeneeded = function(event) 
{  
    event.target.result.createObjectStore('os', { keyPath: null }); 
}