Mercurial > hg > orthanc-databases
comparison 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 |
comparison
equal
deleted
inserted
replaced
21:2e5d2c69d4f9 | 22:1e9bad493475 |
---|---|
80 | 80 |
81 MySQLDatabase db(p); | 81 MySQLDatabase db(p); |
82 db.Open(); | 82 db.Open(); |
83 | 83 |
84 MySQLTransaction t(db); | 84 MySQLTransaction t(db); |
85 db.Execute("DROP DATABASE IF EXISTS " + database, false); | 85 |
86 if (!db.DoesDatabaseExist(t, database)) | |
87 { | |
88 LOG(ERROR) << "Inexistent database, please create it first: " << database; | |
89 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); | |
90 } | |
91 | |
92 db.Execute("DROP DATABASE " + database, false); | |
86 db.Execute("CREATE DATABASE " + database, false); | 93 db.Execute("CREATE DATABASE " + database, false); |
87 t.Commit(); | 94 t.Commit(); |
88 } | 95 } |
89 | 96 |
90 std::auto_ptr<MySQLDatabase> db(new MySQLDatabase(parameters_)); | 97 std::auto_ptr<MySQLDatabase> db(new MySQLDatabase(parameters_)); |