Do NOT set ID on accounts, they should only contain account ID.

This commit is contained in:
Martin Rotter 2021-03-01 07:02:46 +01:00
parent 581b7c08a0
commit 48909d9ef9
3 changed files with 14 additions and 6 deletions

View File

@ -1670,8 +1670,8 @@ void DatabaseQueries::createOverwriteAccount(const QSqlDatabase& db, ServiceRoot
throw ApplicationException(q.lastError().text());
}
else {
account->setId(q.lastInsertId().toInt());
account->setAccountId(account->id());
//account->setId(q.lastInsertId().toInt());
account->setAccountId(q.lastInsertId().toInt());
}
}
@ -1690,8 +1690,14 @@ void DatabaseQueries::createOverwriteAccount(const QSqlDatabase& db, ServiceRoot
q.bindValue(QSL(":proxy_password"), TextFactory::encrypt(proxy.password()));
q.bindValue(QSL(":id"), account->accountId());
q.bindValue(QSL(":custom_data"),
QString::fromUtf8(QJsonDocument::fromVariant(account->customDatabaseData()).toJson(QJsonDocument::JsonFormat::Indented)));
auto custom_data = account->customDatabaseData();
QString serialized_custom_data;
if (!custom_data.isEmpty()) {
serialized_custom_data = QString::fromUtf8(QJsonDocument::fromVariant(custom_data).toJson(QJsonDocument::JsonFormat::Indented));
}
q.bindValue(QSL(":custom_data"), serialized_custom_data);
if (!q.exec()) {
throw ApplicationException(q.lastError().text());

View File

@ -189,8 +189,8 @@ QList<ServiceRoot*> DatabaseQueries::getAccounts(const QSqlDatabase& db, const Q
ServiceRoot* root = new T();
// Load common data.
root->setId(query.value(QSL("id")).toInt());
root->setAccountId(root->id());
//root->setId(query.value(QSL("id")).toInt());
root->setAccountId(query.value(QSL("id")).toInt());
QNetworkProxy proxy(QNetworkProxy::ProxyType(query.value(QSL("proxy_type")).toInt()),
query.value(QSL("proxy_host")).toString(),

View File

@ -13,5 +13,7 @@ FormEditStandardAccount::FormEditStandardAccount(QWidget* parent)
void FormEditStandardAccount::apply() {
FormAccountDetails::apply();
m_account->saveAccountDataToDatabase();
accept();
}