Fixed object level calculation (containing folder's level+1, not folder's level itself); updated schema to match
This commit is contained in:
parent
396cce8a0d
commit
3f398783d1
4 changed files with 10 additions and 5 deletions
|
@ -68,7 +68,7 @@ Scholar.Object.prototype.isEditableField = function(field){
|
||||||
* Build object from database
|
* Build object from database
|
||||||
*/
|
*/
|
||||||
Scholar.Object.prototype.loadFromID = function(id){
|
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 '
|
+ 'FROM objects O '
|
||||||
+ 'LEFT JOIN folders F USING (folderID) '
|
+ 'LEFT JOIN folders F USING (folderID) '
|
||||||
+ 'LEFT JOIN treeOrder ORD ON (O.objectID=ORD.id AND isFolder=0) '
|
+ '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
|
// 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 '
|
+ 'FROM objects O '
|
||||||
+ 'LEFT JOIN folders F USING (folderID) '
|
+ 'LEFT JOIN folders F USING (folderID) '
|
||||||
+ 'LEFT JOIN treeOrder ORD ON (O.objectID=ORD.id AND isFolder=0) '
|
+ 'LEFT JOIN treeOrder ORD ON (O.objectID=ORD.id AND isFolder=0) '
|
||||||
|
|
|
@ -416,6 +416,11 @@ Scholar.DB = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i==5){
|
if (i==5){
|
||||||
|
query("UPDATE folders SET level=-1, parentFolderID=NULL WHERE folderID=0");
|
||||||
|
_updateDBVersion(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i==6){
|
||||||
// do stuff
|
// do stuff
|
||||||
// _updateDBVersion(i);
|
// _updateDBVersion(i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const SCHOLAR_CONFIG = {
|
const SCHOLAR_CONFIG = {
|
||||||
GUID: 'scholar@chnm',
|
GUID: 'scholar@chnm',
|
||||||
DB_FILE: 'scholar.sqlite',
|
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
|
DB_REBUILD: false, // erase DB and recreate from schema
|
||||||
DEBUG_LOGGING: true,
|
DEBUG_LOGGING: true,
|
||||||
DEBUG_TO_CONSOLE: false // dump debug messages to console rather than (much slower) Debug Logger
|
DEBUG_TO_CONSOLE: false // dump debug messages to console rather than (much slower) Debug Logger
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- 3
|
-- 5
|
||||||
|
|
||||||
DROP TABLE IF EXISTS version;
|
DROP TABLE IF EXISTS version;
|
||||||
CREATE TABLE version (
|
CREATE TABLE version (
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
FOREIGN KEY (parentFolderID) REFERENCES folders(folderID)
|
FOREIGN KEY (parentFolderID) REFERENCES folders(folderID)
|
||||||
);
|
);
|
||||||
CREATE INDEX parentFolderID ON folders(parentFolderID);
|
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;
|
DROP TABLE IF EXISTS treeOrder;
|
||||||
CREATE TABLE treeOrder (
|
CREATE TABLE treeOrder (
|
||||||
|
|
Loading…
Reference in a new issue