From 3f398783d178b8598828fd7b073937fb6c74fca5 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 16 May 2006 07:21:31 +0000 Subject: [PATCH] Fixed object level calculation (containing folder's level+1, not folder's level itself); updated schema to match --- chrome/chromeFiles/content/scholar/data_access.js | 4 ++-- chrome/chromeFiles/content/scholar/db.js | 5 +++++ chrome/chromeFiles/content/scholar/scholar.js | 2 +- schema.sql | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/data_access.js b/chrome/chromeFiles/content/scholar/data_access.js index 63647cf15..df9e52e69 100644 --- a/chrome/chromeFiles/content/scholar/data_access.js +++ b/chrome/chromeFiles/content/scholar/data_access.js @@ -68,7 +68,7 @@ Scholar.Object.prototype.isEditableField = function(field){ * Build object from database */ Scholar.Object.prototype.loadFromID = function(id){ - var sql = 'SELECT O.*, lastName AS firstCreator, F.level, ORD.orderIndex ' + var sql = 'SELECT O.*, lastName AS firstCreator, F.level+1 AS level, ORD.orderIndex ' + 'FROM objects O ' + 'LEFT JOIN folders F USING (folderID) ' + 'LEFT JOIN treeOrder ORD ON (O.objectID=ORD.id AND isFolder=0) ' @@ -899,7 +899,7 @@ Scholar.Objects = new function(){ } // Should be the same as query in Scholar.Object.loadFromID, just without objectID clause - var sql = 'SELECT O.*, lastName AS firstCreator, F.level, ORD.orderIndex ' + var sql = 'SELECT O.*, lastName AS firstCreator, F.level+1 AS level, ORD.orderIndex ' + 'FROM objects O ' + 'LEFT JOIN folders F USING (folderID) ' + 'LEFT JOIN treeOrder ORD ON (O.objectID=ORD.id AND isFolder=0) ' diff --git a/chrome/chromeFiles/content/scholar/db.js b/chrome/chromeFiles/content/scholar/db.js index c2b3cdc9a..8a7fe5874 100644 --- a/chrome/chromeFiles/content/scholar/db.js +++ b/chrome/chromeFiles/content/scholar/db.js @@ -416,6 +416,11 @@ Scholar.DB = new function(){ } if (i==5){ + query("UPDATE folders SET level=-1, parentFolderID=NULL WHERE folderID=0"); + _updateDBVersion(i); + } + + if (i==6){ // do stuff // _updateDBVersion(i); } diff --git a/chrome/chromeFiles/content/scholar/scholar.js b/chrome/chromeFiles/content/scholar/scholar.js index da31a633f..ea6c0c3c8 100644 --- a/chrome/chromeFiles/content/scholar/scholar.js +++ b/chrome/chromeFiles/content/scholar/scholar.js @@ -1,7 +1,7 @@ const SCHOLAR_CONFIG = { GUID: 'scholar@chnm', DB_FILE: 'scholar.sqlite', - DB_VERSION: 3, + DB_VERSION: 5, // must match version at top of schema.sql DB_REBUILD: false, // erase DB and recreate from schema DEBUG_LOGGING: true, DEBUG_TO_CONSOLE: false // dump debug messages to console rather than (much slower) Debug Logger diff --git a/schema.sql b/schema.sql index 4db586877..7c218ed99 100644 --- a/schema.sql +++ b/schema.sql @@ -1,4 +1,4 @@ --- 3 +-- 5 DROP TABLE IF EXISTS version; CREATE TABLE version ( @@ -112,7 +112,7 @@ FOREIGN KEY (parentFolderID) REFERENCES folders(folderID) ); CREATE INDEX parentFolderID ON folders(parentFolderID); - INSERT INTO folders VALUES (0, 'root', 0, 0); + INSERT INTO folders VALUES (0, 'root', NULL, -1); DROP TABLE IF EXISTS treeOrder; CREATE TABLE treeOrder (