Commit 5e8f6c1d authored by Denis Kurz's avatar Denis Kurz
Browse files

Add needed columns to QueryBuilder explicitly

Summary:
The former fullColumnNames approach relied on the number and order of
columns returned by fullColumnNames to not change. Requesting the
required column explicitly makes this more robust.

Reviewers: dvratil

Reviewed By: dvratil

Subscribers: #kde_pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D7492
parent e5071bd2
...@@ -74,7 +74,9 @@ QSqlQuery TagFetchHelper::buildAttributeQuery(qint64 id) ...@@ -74,7 +74,9 @@ QSqlQuery TagFetchHelper::buildAttributeQuery(qint64 id)
QSqlQuery TagFetchHelper::buildTagQuery() QSqlQuery TagFetchHelper::buildTagQuery()
{ {
QueryBuilder qb(Tag::tableName()); QueryBuilder qb(Tag::tableName());
qb.addColumns(Tag::fullColumnNames()); qb.addColumn(Tag::idFullColumnName());
qb.addColumn(Tag::gidFullColumnName());
qb.addColumn(Tag::parentIdFullColumnName());
qb.addJoin(QueryBuilder::InnerJoin, TagType::tableName(), qb.addJoin(QueryBuilder::InnerJoin, TagType::tableName(),
Tag::typeIdFullColumnName(), TagType::idFullColumnName()); Tag::typeIdFullColumnName(), TagType::idFullColumnName());
...@@ -126,9 +128,9 @@ bool TagFetchHelper::fetchTags() ...@@ -126,9 +128,9 @@ bool TagFetchHelper::fetchTags()
response->setId(tagId); response->setId(tagId);
response->setGid(Utils::variantToByteArray(tagQuery.value(1))); response->setGid(Utils::variantToByteArray(tagQuery.value(1)));
response->setParentId(tagQuery.value(2).toLongLong()); response->setParentId(tagQuery.value(2).toLongLong());
response->setType(Utils::variantToByteArray(tagQuery.value(4))); response->setType(Utils::variantToByteArray(tagQuery.value(3)));
if (mConnection->context()->resource().isValid()) { if (mConnection->context()->resource().isValid()) {
response->setRemoteId(Utils::variantToByteArray(tagQuery.value(5))); response->setRemoteId(Utils::variantToByteArray(tagQuery.value(4)));
} }
QMap<QByteArray, QByteArray> tagAttributes; QMap<QByteArray, QByteArray> tagAttributes;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment