| 410 | } |
| 411 | |
| 412 | bool SimpleDatabase::doesTableExist(Tables const& table) { |
| 413 | QSqlQuery tableExistanceQuery(database); |
| 414 | tableExistanceQuery.prepare("SELECT `name` FROM `sqlite_master` WHERE `type` = 'table' AND `name` = :tableName"); |
| 415 | |
| 416 | QString const tableName(getTableName(table)); |
| 417 | tableExistanceQuery.bindValue(QStringLiteral(":tableName"), QVariant(tableName)); |
| 418 | |
| 419 | if (tableExistanceQuery.exec() && tableExistanceQuery.isSelect()) { |
| 420 | return tableExistanceQuery.next(); |
| 421 | } else { |
| 422 | throw openmittsu::exceptions::InternalErrorException() << "Could not execute table existance query for table " << tableName.toStdString() << "."; |
| 423 | return false; |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | void SimpleDatabase::setTableVersion(Tables const& table, int tableVersion) { |
| 428 | QSqlQuery query(database); |