Mercurial > hg > orthanc-databases
diff MySQL/Plugins/MySQLIndex.cpp @ 22:1e9bad493475
prevent running unit tests on a non-existing db
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 11 Jul 2018 14:39:59 +0200 |
parents | 9e419261f1c9 |
children | b2ff1cd2907a |
line wrap: on
line diff
--- a/MySQL/Plugins/MySQLIndex.cpp Tue Jul 10 14:33:05 2018 +0200 +++ b/MySQL/Plugins/MySQLIndex.cpp Wed Jul 11 14:39:59 2018 +0200 @@ -82,7 +82,14 @@ db.Open(); MySQLTransaction t(db); - db.Execute("DROP DATABASE IF EXISTS " + database, false); + + if (!db.DoesDatabaseExist(t, database)) + { + LOG(ERROR) << "Inexistent database, please create it first: " << database; + throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); + } + + db.Execute("DROP DATABASE " + database, false); db.Execute("CREATE DATABASE " + database, false); t.Commit(); }