Down to 1 test failure

This commit is contained in:
David Humphrey (:humph) david.humphrey@senecacollege.ca 2013-11-27 19:35:52 -05:00
parent c92d3a6c5f
commit d5db4c51b9
2 changed files with 10 additions and 7 deletions

View File

@ -13,7 +13,7 @@ define(function(require) {
return;
}
// Either do readTransaction() (read-only) or transaction() (read/write)
db[isReadOnly ? 'transaction' : 'readTransaction'](function(transaction) {
db[isReadOnly ? 'readTransaction' : 'transaction'](function(transaction) {
that.transaction = transaction;
callback(transaction);
});
@ -33,8 +33,9 @@ define(function(require) {
};
WebSQLContext.prototype.get = function(key, callback) {
function onSuccess(transaction, result) {
if(result.rows.length !== 1) {
callback("[WebSQLContext] Error: expected 1 row for get operation.");
if(result.rows.length === 0) {
// Key not found, return null
callback(null, null);
return;
}
callback(null, result.rows.item(0).data);
@ -43,7 +44,7 @@ define(function(require) {
callback(error);
}
this.getTransaction(function(transaction) {
transaction.executeSql("SELECT * FROM " + FILE_STORE_NAME + " WHERE id = ?",
transaction.executeSql("SELECT data FROM " + FILE_STORE_NAME + " WHERE id = ? LIMIT 1",
[key], onSuccess, onError);
});
};
@ -110,7 +111,7 @@ define(function(require) {
}
// Keep track of whether we're accessing this db for the first time
// and therefore needs to get formatted.
transaction.executeSql("SELECT COUNT(id) AS count FROM " + FILE_STORE_NAME,
transaction.executeSql("SELECT COUNT(id) AS count FROM " + FILE_STORE_NAME + ";",
[], gotCount, onError);
}

View File

@ -5,7 +5,9 @@ define(["IDBFS"], function(IDBFS) {
function wipeDB(provider) {
var context = provider.getReadWriteContext();
context.clear(function(err) {
console.error("Problem clearing WebSQL db: " + err);
if(err) {
console.error("Problem clearing WebSQL db: [" + err.code + "] - " + err.message);
}
});
}
@ -35,7 +37,7 @@ define(["IDBFS"], function(IDBFS) {
var complete = false;
var _error, _result;
var provider = this.provider = this.provider = new IDBFS.FileSystem.providers.WebSQL(WEBSQL_NAME);
var provider = this.provider = new IDBFS.FileSystem.providers.WebSQL(WEBSQL_NAME);
provider.open(function(err, firstAccess) {
_error = err;
_result = firstAccess;