From 393d19ca85e9cd6231b16d9731730496dc578c4a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 8 Jun 2006 00:16:35 +0000 Subject: [PATCH] Fix SQL error on middle creator remove Added creatorTypeID to the PK in itemCreators, because a creator could conceivably have two roles on an item Throw an error if attempt to save() an item with two identical creator/creatorTypeID combinations, since, assuming this shouldn't be allowed (i.e. we don't have a four-column PK), there's really no way to handle this elegantly on my end -- interface code can use new method Item.creatorExists(firstName, lastName, creatorTypeID, skipIndex), with skipIndex set to the current index, to make sure this isn't done --- .../content/scholar/xpcom/data_access.js | 66 +++++++++++++------ .../content/scholar/xpcom/schema.js | 8 +-- schema.sql | 4 +- 3 files changed, 53 insertions(+), 25 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js index e2543f58e..9e80bf1be 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/data_access.js +++ b/chrome/chromeFiles/content/scholar/xpcom/data_access.js @@ -204,11 +204,12 @@ Scholar.Item.prototype.setCreator = function(orderIndex, firstName, lastName, cr lastName = ''; } + // If creator at this position hasn't changed, cancel if (this._creators.has(orderIndex) && this._creators.get(orderIndex)['firstName']==firstName && this._creators.get(orderIndex)['lastName']==lastName && this._creators.get(orderIndex)['creatorTypeID']==creatorTypeID){ - return true; + return false; } if (!creatorTypeID){ @@ -250,6 +251,23 @@ Scholar.Item.prototype.removeCreator = function(orderIndex){ } +Scholar.Item.prototype.creatorExists = function(firstName, lastName, creatorTypeID, skipIndex){ + for (var j=0, len=this.numCreators(); j