commit 0fe53898583997a0b60a4da9d57c0fba97649dfe
parent 6539cace598c7475ba6e90a56b808e59603ea8ee
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 2 Dec 2009 08:11:37 +0000
Remove any remaining blank tags and enforce on DB level
Diffstat:
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js
@@ -2487,6 +2487,11 @@ Zotero.Schema = new function(){
Zotero.DB.query("UPDATE itemNotes SET sourceItemID=NULL WHERE sourceItemID IN (SELECT itemID FROM items WHERE itemTypeID IN (1,14))");
}
+ if (i==66) {
+ Zotero.DB.query("DELETE FROM itemTags WHERE tagID IN (SELECT tagID FROM tags WHERE TRIM(name)='')");
+ Zotero.DB.query("DELETE FROM tags WHERE TRIM(name)=''");
+ }
+
Zotero.wait();
}
diff --git a/triggers.sql b/triggers.sql
@@ -1,4 +1,4 @@
--- 14
+-- 15
-- Triggers to validate date field
DROP TRIGGER IF EXISTS insert_date_field;
@@ -1388,3 +1388,21 @@ CREATE TRIGGER fku_proxies_proxyID_proxyHosts_proxyID
SELECT RAISE(ABORT, 'update on table "proxies" violates foreign key constraint "fku_proxies_proxyID_proxyHosts_proxyID"')
WHERE (SELECT COUNT(*) FROM proxyHosts WHERE proxyID = OLD.proxyID) > 0;
END;
+
+-- Make sure tags aren't empty
+DROP TRIGGER IF EXISTS fki_tags;
+CREATE TRIGGER fki_tags
+BEFORE INSERT ON tags
+ FOR EACH ROW BEGIN
+ SELECT RAISE(ABORT, 'Tag cannot be blank')
+ WHERE TRIM(NEW.name)='';
+ END;
+
+DROP TRIGGER IF EXISTS fku_tags;
+CREATE TRIGGER fku_tags
+ BEFORE UPDATE OF name ON tags
+ FOR EACH ROW BEGIN
+ SELECT RAISE(ABORT, 'Tag cannot be blank')
+ WHERE TRIM(NEW.name)='';
+ END;
+
diff --git a/userdata.sql b/userdata.sql
@@ -1,4 +1,4 @@
--- 65
+-- 66
-- This file creates tables containing user-specific data for new users --
-- any changes made here must be mirrored in transition steps in schema.js::_migrateSchema()