mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 706088 Make .put allow no key being provided if it's an autoIncrement object store. r=bent
This commit is contained in:
parent
c650c15043
commit
e6b29675f2
@ -1109,8 +1109,8 @@ IDBObjectStore::AddOrPut(const jsval& aValue,
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Put requires a key.
|
||||
if (aOverwrite && key.IsUnset()) {
|
||||
// Put requires a key, unless this is an autoIncrementing objectStore.
|
||||
if (aOverwrite && !mAutoIncrement && key.IsUnset()) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
|
||||
}
|
||||
|
||||
@ -1793,7 +1793,7 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
||||
}
|
||||
|
||||
// If we are supposed to generate a key, get the new id.
|
||||
if (autoIncrement && !mOverwrite) {
|
||||
if (autoIncrement && !mayOverwrite) {
|
||||
#ifdef DEBUG
|
||||
PRInt64 oldKey = unsetKey ? 0 : mKey.ToInteger();
|
||||
#endif
|
||||
|
@ -61,18 +61,18 @@
|
||||
|
||||
try {
|
||||
objectStore.put({});
|
||||
ok(false, "put with no key should throw!");
|
||||
ok(true, "put with no key should not throw with autoIncrement!");
|
||||
}
|
||||
catch (e) {
|
||||
ok(true, "put with no key threw");
|
||||
ok(false, "put with no key threw with autoIncrement");
|
||||
}
|
||||
|
||||
try {
|
||||
objectStore.put({});
|
||||
ok(false, "put with no key should throw!");
|
||||
ok(true, "put with no key should not throw with autoIncrement!");
|
||||
}
|
||||
catch (e) {
|
||||
ok(true, "put with no key threw");
|
||||
ok(false, "put with no key threw with autoIncrement");
|
||||
}
|
||||
|
||||
try {
|
||||
@ -247,18 +247,18 @@
|
||||
|
||||
try {
|
||||
objectStore.put({});
|
||||
ok(false, "put with no key should throw!");
|
||||
ok(true, "put with no key should not throw with autoIncrement!");
|
||||
}
|
||||
catch (e) {
|
||||
ok(true, "put with no key threw");
|
||||
ok(false, "put with no key threw with autoIncrement");
|
||||
}
|
||||
|
||||
try {
|
||||
objectStore.put({});
|
||||
ok(false, "put with no key should throw!");
|
||||
ok(true, "put with no key should not throw with autoIncrement!");
|
||||
}
|
||||
catch (e) {
|
||||
ok(true, "put with no key threw");
|
||||
ok(false, "put with no key threw with autoIncrement");
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -29,7 +29,7 @@
|
||||
let objectStore = db.createObjectStore(objectStoreName,
|
||||
{ autoIncrement: 1 });
|
||||
|
||||
request = objectStore.add(testString.value);
|
||||
request = objectStore.put(testString.value);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function(event) {
|
||||
testString.key = event.target.result;
|
||||
@ -40,7 +40,7 @@
|
||||
};
|
||||
};
|
||||
|
||||
request = objectStore.add(testInt.value);
|
||||
request = objectStore.put(testInt.value);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function(event) {
|
||||
testInt.key = event.target.result;
|
||||
|
Loading…
Reference in New Issue
Block a user