Revision 2fedfe76
Von Christian Ehringfeld vor mehr als 8 Jahren hinzugefügt
src/querybuilder.cpp | ||
---|---|---|
if (!rc) {
|
||
QSqlQuery q = this->database->getQuery(this->createTable(tableName,
|
||
tableDefinition));
|
||
if (this->database->exec(q)) {
|
||
if (createRelationTables) {
|
||
auto relTables = this->generateRelationTables(entity);
|
||
auto i = relTables.constBegin();
|
||
while (i != relTables.constEnd()) {
|
||
auto query = this->database->getQuery(this->createTable(i.key(),
|
||
i.value()));
|
||
this->database->exec(query);
|
||
++i;
|
||
}
|
||
}
|
||
this->schema->getTableSchema(tableName);
|
||
if (this->database->exec(q) && (!createRelationTables || (createRelationTables
|
||
&& this->createRelationTables(entity)))) {
|
||
rc = true;
|
||
} else {
|
||
qWarning() << "Table " << entity->getTablename() << " could not be created.";
|
||
}
|
||
this->schema->getTableSchema(tableName);
|
||
}
|
||
}
|
||
return rc;
|
||
}
|
||
|
||
bool QueryBuilder::createRelationTables(const QSharedPointer<Entity> &entity)
|
||
const {
|
||
bool ok = true;
|
||
auto relTables = this->generateRelationTables(entity);
|
||
auto i = relTables.constBegin();
|
||
while (i != relTables.constEnd()) {
|
||
auto query = this->database->getQuery(this->createTable(i.key(), i.value()));
|
||
if (!this->database->exec(query)) {
|
||
ok = false;
|
||
qWarning() << "Relational table for table " << entity->getTablename() <<
|
||
" could not be created." << " Tablename:" << i.key();
|
||
break;
|
||
}
|
||
++i;
|
||
}
|
||
return ok;
|
||
}
|
||
|
||
bool QueryBuilder::createIndices(const QSharedPointer<Entity> &entity) const {
|
||
bool ok = true;
|
||
QStringList queries = QStringList();
|
Auch abrufbar als: Unified diff
ticket #582 and startup method improvement