This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 11257 - Should IDBCursor.update be able to create a new entry?
Summary: Should IDBCursor.update be able to create a new entry?
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: Indexed Database API (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-08 11:12 UTC by Jonas Sicking (Not reading bugmail)
Modified: 2011-03-08 20:03 UTC (History)
3 users (show)

See Also:


Attachments

Description Jonas Sicking (Not reading bugmail) 2010-11-08 11:12:24 UTC
What should happen in the following case:

db.transaction(["foo"]).objectStore("foo").openCursor().onsuccess = function(e) {
  var cursor = e.result;
  if (!cursor)
    return;

  cursor.delete();
  cursor.update({ id: 1234, value: "Benny" });
}


This situation can of course arrive in more subtle ways:

os = db.transaction(["foo"]).objectStore("foo");
os.openCursor().onsuccess = function(e) {
  var cursor = e.result;
  if (!cursor)
    return;

  cursor.update({ id: 1234, value: "Benny" });
}
os.delete(1234);


As specified, IDBCursor.update behaves just like IDBObjectStore.put and just creates a new entry, but this might be somewhat unexpected behavior.
Comment 1 Jeremy Orlow 2011-03-08 04:20:58 UTC
Based on the resulting thread, it seems the answer is no.  So we should probably take out the issues in the spec related to this.
Comment 2 Jonas Sicking (Not reading bugmail) 2011-03-08 20:02:47 UTC
The answer is "yes". Checked in a clarification to that effect.