Skip to content

Commit

Permalink
videodb: fix SQL query in CleanDatabase() not considering NULLed fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Montellese committed Nov 23, 2013
1 parent dc6d3b2 commit a52226d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions xbmc/video/VideoDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8217,7 +8217,11 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se
}

CLog::Log(LOGDEBUG, "%s: Cleaning paths that don't exist and have content set...", __FUNCTION__);
sql = "select * from path where not (strContent='' and strSettings='' and strHash='' and exclude!=1)";
sql = "select * from path "
"where not ((strContent IS NULL OR strContent='') "
"and (strSettings IS NULL OR strSettings='') "
"and (strHash IS NULL OR strHash='') "
"and (exclude IS NULL OR exclude!=1))";
m_pDS->query(sql.c_str());
CStdString strIds;
while (!m_pDS->eof())
Expand Down Expand Up @@ -8248,7 +8252,7 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se
"join tvshowlinkpath on tvshow.idShow=tvshowlinkpath.idShow "
"join path on path.idPath=tvshowlinkpath.idPath "
"where tvshow.idShow not in (select idShow from episode) "
"and path.strContent=''";
"and (path.strContent IS NULL OR path.strContent='')";
m_pDS->query(sql.c_str());
while (!m_pDS->eof())
{
Expand Down Expand Up @@ -8315,7 +8319,11 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se
}

CLog::Log(LOGDEBUG, "%s: Cleaning path table", __FUNCTION__);
sql = StringUtils::Format("delete from path where strContent='' and strSettings='' and strHash='' and exclude!=1 "
sql = StringUtils::Format("delete from path "
"where (strContent is null or strContent='') "
"and (strSettings is null or strSettings='') "
"and (strHash is null or strHash='') "
"and (exclude is null or exclude!=1) "
"and idPath not in (select distinct idPath from files) "
"and idPath not in (select distinct idPath from tvshowlinkpath) "
"and idPath not in (select distinct c%02d from movie) "
Expand Down

0 comments on commit a52226d

Please sign in to comment.