mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 13:04:28 -04:00
PRAGMA foreign_keys = ON added on update, it seems that the query on database load doesn't work (weird)
parent!=0 check add to avoid crashes if the DB become corrupted.
This commit is contained in:
@ -256,7 +256,7 @@ void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
|||||||
item->id = record.value("id").toULongLong();
|
item->id = record.value("id").toULongLong();
|
||||||
//la inserci<63>n de hijos se hace de forma ordenada
|
//la inserci<63>n de hijos se hace de forma ordenada
|
||||||
TreeItem * parent = items.value(record.value("parentId").toULongLong());
|
TreeItem * parent = items.value(record.value("parentId").toULongLong());
|
||||||
if(parent !=0)
|
if(parent !=0) //TODO if parent==0 the parent of item was removed from the DB and delete on cascade didn't work, ERROR.
|
||||||
parent->appendChild(item);
|
parent->appendChild(item);
|
||||||
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
|
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
|
||||||
items.insert(item->id,item);
|
items.insert(item->id,item);
|
||||||
|
@ -92,7 +92,7 @@ void LibraryCreator::run()
|
|||||||
creation = false;
|
creation = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//QSqlQuery pragma("PRAGMA foreign_keys = ON",_database);
|
QSqlQuery pragma("PRAGMA foreign_keys = ON",_database);
|
||||||
_database.transaction();
|
_database.transaction();
|
||||||
update(QDir(_source));
|
update(QDir(_source));
|
||||||
_database.commit();
|
_database.commit();
|
||||||
|
Reference in New Issue
Block a user