commit 81d389a6c48f4b82a6e306eba77a7c75d9233920
parent 2175700312703e3d32052f6c004b81dc97e7e08d
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 7 Sep 2011 04:13:38 +0000
Use INSERT OR IGNORE for delete item relations
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/data/relation.js b/chrome/content/zotero/xpcom/data/relation.js
@@ -158,7 +158,13 @@ Zotero.Relation.prototype.save = function () {
throw ("Missing object in Zotero.Relation.save()");
}
- var sql = "INSERT INTO relations "
+ // Hack to deal with duplicate relations inserted in the wrong order in 3.0b1
+ //
+ // This could possibly be addressed by a database upgrade step that deleted
+ // any deletedItemPredicate relations _from_ existing non-trashed items
+ var ignore = this.predicate == Zotero.Relations.deletedItemPredicate ? "OR IGNORE " : "";
+
+ var sql = "INSERT " + ignore + "INTO relations "
+ "(libraryID, subject, predicate, object, clientDateModified) "
+ "VALUES (?, ?, ?, ?, ?)";
var insertID = Zotero.DB.query(