commit 8f344872055eb4bae690da83cbf2197d42e9b864
parent 60ada26e8d7747c8ee6b32ce585f8cc10a306d9d
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 2 Jun 2006 16:37:17 +0000
Fixed error in new item itemData insert (trying to bind across multiple statements) (yes we need unit tests)
Missing parens in Items._load() causing it to load all items in !all mode
Show type in debug output when binding params
Diffstat:
3 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js
@@ -410,7 +410,7 @@ Scholar.Item.prototype.save = function(){
if (Scholar.DB.valueQuery(sql2)){
sql = 'UPDATE itemCreators SET creatorID=?, '
+ 'creatorTypeID=? WHERE itemID=?'
- + " AND orderIndex=?;\n";
+ + " AND orderIndex=?";
sqlValues = [
{'int':creatorID},
@@ -423,7 +423,7 @@ Scholar.Item.prototype.save = function(){
}
// Otherwise insert
else {
- sql = "INSERT INTO itemCreators VALUES (?,?,?,?);\n";
+ sql = "INSERT INTO itemCreators VALUES (?,?,?,?)";
sqlValues = [
{'int':itemID},
@@ -468,7 +468,7 @@ Scholar.Item.prototype.save = function(){
else {
sqlValues.push({'string':this.getField(fieldID)});
}
- sql += " WHERE itemID=? AND fieldID=?;\n";
+ sql += " WHERE itemID=? AND fieldID=?";
sqlValues.push(
{'int':this.getID()},
@@ -478,8 +478,8 @@ Scholar.Item.prototype.save = function(){
Scholar.DB.query(sql, sqlValues);
}
else {
- sql = "INSERT INTO itemData VALUES (?,?,?);\n";
-
+ sql = "INSERT INTO itemData VALUES (?,?,?)";
+
sqlValues = [
{'int':this.getID()},
{'int':fieldID},
@@ -505,7 +505,7 @@ Scholar.Item.prototype.save = function(){
if (del.length){
sql = 'DELETE from itemData '
+ 'WHERE itemID=' + this.getID() + ' '
- + 'AND fieldID IN (' + del.join() + ");\n";
+ + 'AND fieldID IN (' + del.join() + ")";
Scholar.DB.query(sql);
}
}
@@ -559,9 +559,6 @@ Scholar.Item.prototype.save = function(){
// Set itemData
if (this._changedItemData.length){
- sql = '';
- sqlValues = [];
-
for (fieldID in this._changedItemData.items){
if (!this.getField(fieldID)){
continue;
@@ -570,12 +567,12 @@ Scholar.Item.prototype.save = function(){
// TODO: update DB methods so that this can be
// implemented as a prepared statement that gets
// called multiple times
- sql += "INSERT INTO itemData VALUES (?,?,?);\n";
+ sql = "INSERT INTO itemData VALUES (?,?,?)";
- sqlValues.push(
+ sqlValues = [
{'int':itemID},
{'int':fieldID}
- );
+ ];
if (Scholar.ItemFields.isInteger(fieldID)){
sqlValues.push({'int':this.getField(fieldID)});
@@ -583,9 +580,7 @@ Scholar.Item.prototype.save = function(){
else {
sqlValues.push({'string':this.getField(fieldID)});
}
- }
-
- if (sql){
+
Scholar.DB.query(sql, sqlValues);
}
}
@@ -923,7 +918,7 @@ Scholar.Items = new function(){
+ 'FROM items I '
+ 'LEFT JOIN itemCreators IC ON (I.itemID=IC.itemID) '
+ 'LEFT JOIN creators C ON (IC.creatorID=C.creatorID) '
- + 'WHERE IC.orderIndex=0 OR IC.orderIndex IS NULL';
+ + 'WHERE (IC.orderIndex=0 OR IC.orderIndex IS NULL)';
if (arguments[0]!='all'){
sql += ' AND I.itemID IN (' + Scholar.join(arguments,',') + ')';
diff --git a/chrome/chromeFiles/content/scholar/xpcom/db.js b/chrome/chromeFiles/content/scholar/xpcom/db.js
@@ -170,12 +170,12 @@ Scholar.DB = new function(){
if (statement && params){
for (var i=0; i<params.length; i++){
if (typeof params[i]['int'] != 'undefined'){
- Scholar.debug('Binding parameter ' + (i+1) + ': ' +
+ Scholar.debug('Binding parameter ' + (i+1) + ' of type int: ' +
params[i]['int'],5);
statement.bindInt32Parameter(i,params[i]['int']);
}
else if (typeof params[i]['string'] != 'undefined'){
- Scholar.debug('Binding parameter ' + (i+1) + ': "' +
+ Scholar.debug('Binding parameter ' + (i+1) + ' of type string: "' +
params[i]['string'] + '"',5);
statement.bindUTF8StringParameter(i,params[i]['string']);
}
diff --git a/chrome/chromeFiles/content/scholar/xpcom/notifier.js b/chrome/chromeFiles/content/scholar/xpcom/notifier.js
@@ -74,7 +74,7 @@ Scholar.Notifier = new function(){
}
function _unregister(type, hash){
- Scholar.debug('Unregistering ' + type + ' in notifier with hash ' + hash, 4);
+ Scholar.debug("Unregistering ' + type + ' in notifier with hash '" + hash + "'", 4);
delete _observers[type][hash];
}
}