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 11394 - We should throw if continue() is called with a key <= the current position
Summary: We should throw if continue() is called with a key <= the current position
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: Jeremy Orlow
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-23 23:50 UTC by Jonas Sicking (Not reading bugmail)
Modified: 2011-03-08 00:53 UTC (History)
3 users (show)

See Also:


Attachments

Description Jonas Sicking (Not reading bugmail) 2010-11-23 23:50:05 UTC
(The below assumes a forward iterating cursor, opposite applies for a reverse iterating cursor of course).

The spec currently states that when calling IDBCursor.continue and passing in a key, the cursor moves to the first record which is greater than the current position, and greater than or equal to the passed in key.

As we implemented this we realized that this makes the situation when someone passes in a key which is less than or equal to the current position very strange. The effect is that the key argument is ignored.

However most likely this was done in error. Worst case, the author might have thought that the cursor would go back to the first entry whose key is greater than or equal to the passed in key, ignoring the current position.

One example of buggy code would be displaying a sales-table with 10 entries from every employee name. If the code ends up passing in a key which is less than or equal to the passed in key, the code likely contains an error.

So a better behavior would be to throw if the passed in key is less than or equal to the cursors current position. This makes it more clear that an error occurred, as well as helps a debugger detect the exception and display the current program state.
Comment 1 Jeremy Orlow 2011-03-04 04:02:08 UTC
What error should we throw?  DATA_ERR?
Comment 2 Jeremy Orlow 2011-03-08 00:53:12 UTC
Jonas just fixed this.