Fixed "UNIQUE constraint failed: Statistics.id" error when loading a previous map with last id saved in Statistics not in Node table (this happened when ignored locations are not saved to database).

This commit is contained in:
matlabbe
2016-10-29 18:12:27 -04:00
parent 9123889876
commit 9e0b45e27a
2 changed files with 10 additions and 1 deletions

View File

@@ -783,6 +783,15 @@ void DBDriver::getLastNodeId(int & id) const
_dbSafeAccessMutex.lock();
this->getLastIdQuery("Node", id);
int statisticsId = 0;
if(uStrNumCmp(this->getDatabaseVersion(), "0.11.11") >= 0)
{
this->getLastIdQuery("Statistics", statisticsId);
if(statisticsId > id)
{
id = statisticsId;
}
}
_dbSafeAccessMutex.unlock();
}

View File

@@ -3163,7 +3163,7 @@ void DBDriverSqlite3::updateOccupancyGridQuery(
void DBDriverSqlite3::addStatisticsQuery(const Statistics & statistics) const
{
UDEBUG("");
UDEBUG("Ref ID = %d", statistics.refImageId());
if(_ppDb)
{
std::string type;