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:
Luis Ángel San Martín
2013-06-21 10:23:04 +02:00
parent 07db7ff6ef
commit 8b00e649b8
2 changed files with 2 additions and 2 deletions

View File

@ -256,7 +256,7 @@ void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
item->id = record.value("id").toULongLong();
//la inserci<63>n de hijos se hace de forma ordenada
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);
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
items.insert(item->id,item);

View File

@ -92,7 +92,7 @@ void LibraryCreator::run()
creation = false;
return;
}
//QSqlQuery pragma("PRAGMA foreign_keys = ON",_database);
QSqlQuery pragma("PRAGMA foreign_keys = ON",_database);
_database.transaction();
update(QDir(_source));
_database.commit();