Bug 36513 - Wrong error code on db.transaction error callback
Summary: Wrong error code on db.transaction error callback
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.6
: P2 Normal
Assignee: Nobody
URL: http://dev.w3.org/html5/webdatabase/#...
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-23 17:44 PDT by Robin L
Modified: 2010-03-23 17:44 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robin L 2010-03-23 17:44:46 PDT
Using the offline database API...
When trying to add a new row to an existing table with unique id's, with an id that is already present in the table and an error callback is defined, then the error code for the error in the callback is wrong. Normally it should have code == 6, for a constraint error (because the unique id is already defined in the table), however it returns code == 1. The error message however is correct.

Code to reproduce (run twice, as the error will only occur after the table has been created the first time) :

db = openDatabase('Test', '1.0', 'HTML5 Web Database API test', 1024*1024*1);
if(db) {
    db.transaction(function(tx) {
        tx.executeSql('CREATE TABLE IF NOT EXISTS test (id unique, text)');
        tx.executeSql('INSERT INTO test (id, text) VALUES (1, "foobar")');
    }, 
    function(error) {  /* Error callback */
        alert( "Error code : " + error.code + " (should be 6)\n Error message : " + error.message );
    });
}

Definition or error codes : http://dev.w3.org/html5/webdatabase/#dom-sqlexception-code-constraint