summaryrefslogtreecommitdiffstats
path: root/dom/indexedDB/KeyPath.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/indexedDB/KeyPath.cpp')
-rw-r--r--dom/indexedDB/KeyPath.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/dom/indexedDB/KeyPath.cpp b/dom/indexedDB/KeyPath.cpp
index 5cad164296..f27ddd007a 100644
--- a/dom/indexedDB/KeyPath.cpp
+++ b/dom/indexedDB/KeyPath.cpp
@@ -329,8 +329,9 @@ bool KeyPath::AppendStringWithValidation(const nsAString& aString) {
return false;
}
-nsresult KeyPath::ExtractKey(JSContext* aCx, const JS::Value& aValue,
- Key& aKey) const {
+nsresult KeyPath::ExtractKey(JSContext* aCx, const JS::Value& aValue, Key& aKey,
+ const VoidOrObjectStoreKeyPathString&
+ aAutoIncrementedObjectStoreKeyPath) const {
uint32_t len = mStrings.Length();
JS::Rooted<JS::Value> value(aCx);
@@ -341,6 +342,17 @@ nsresult KeyPath::ExtractKey(JSContext* aCx, const JS::Value& aValue,
GetJSValFromKeyPathString(aCx, aValue, mStrings[i], value.address(),
DoNotCreateProperties, nullptr, nullptr);
if (NS_FAILED(rv)) {
+ if (!aAutoIncrementedObjectStoreKeyPath.IsVoid() &&
+ mStrings[i].Equals(aAutoIncrementedObjectStoreKeyPath)) {
+ // We are extracting index keys of an object to be added if
+ // object store key path for a string key is provided.
+ // Because the autoIncrement primary key is part of
+ // this index key but is not defined in |aValue|, so we reserve
+ // the space here to update the key later in parent.
+ aKey.ReserveAutoIncrementKey(IsArray() && i == 0);
+ continue;
+ }
+
return rv;
}