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;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put requires a key.
|
// Put requires a key, unless this is an autoIncrementing objectStore.
|
||||||
if (aOverwrite && key.IsUnset()) {
|
if (aOverwrite && !mAutoIncrement && key.IsUnset()) {
|
||||||
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
|
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 we are supposed to generate a key, get the new id.
|
||||||
if (autoIncrement && !mOverwrite) {
|
if (autoIncrement && !mayOverwrite) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
PRInt64 oldKey = unsetKey ? 0 : mKey.ToInteger();
|
PRInt64 oldKey = unsetKey ? 0 : mKey.ToInteger();
|
||||||
#endif
|
#endif
|
||||||
|
@ -61,18 +61,18 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
objectStore.put({});
|
objectStore.put({});
|
||||||
ok(false, "put with no key should throw!");
|
ok(true, "put with no key should not throw with autoIncrement!");
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
ok(true, "put with no key threw");
|
ok(false, "put with no key threw with autoIncrement");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
objectStore.put({});
|
objectStore.put({});
|
||||||
ok(false, "put with no key should throw!");
|
ok(true, "put with no key should not throw with autoIncrement!");
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
ok(true, "put with no key threw");
|
ok(false, "put with no key threw with autoIncrement");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -247,18 +247,18 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
objectStore.put({});
|
objectStore.put({});
|
||||||
ok(false, "put with no key should throw!");
|
ok(true, "put with no key should not throw with autoIncrement!");
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
ok(true, "put with no key threw");
|
ok(false, "put with no key threw with autoIncrement");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
objectStore.put({});
|
objectStore.put({});
|
||||||
ok(false, "put with no key should throw!");
|
ok(true, "put with no key should not throw with autoIncrement!");
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
ok(true, "put with no key threw");
|
ok(false, "put with no key threw with autoIncrement");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
let objectStore = db.createObjectStore(objectStoreName,
|
let objectStore = db.createObjectStore(objectStoreName,
|
||||||
{ autoIncrement: 1 });
|
{ autoIncrement: 1 });
|
||||||
|
|
||||||
request = objectStore.add(testString.value);
|
request = objectStore.put(testString.value);
|
||||||
request.onerror = errorHandler;
|
request.onerror = errorHandler;
|
||||||
request.onsuccess = function(event) {
|
request.onsuccess = function(event) {
|
||||||
testString.key = event.target.result;
|
testString.key = event.target.result;
|
||||||
@ -40,7 +40,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
request = objectStore.add(testInt.value);
|
request = objectStore.put(testInt.value);
|
||||||
request.onerror = errorHandler;
|
request.onerror = errorHandler;
|
||||||
request.onsuccess = function(event) {
|
request.onsuccess = function(event) {
|
||||||
testInt.key = event.target.result;
|
testInt.key = event.target.result;
|
||||||
|
Loading…
Reference in New Issue
Block a user