From b89fc2271b05fc2834c89a1549a6dc3e8fbe9255 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 20 Jun 2016 18:39:52 +0200 Subject: Fixed cleanup of date indexes --- common/typeindex.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/common/typeindex.cpp b/common/typeindex.cpp index 1a50bfe..05bbf5c 100644 --- a/common/typeindex.cpp +++ b/common/typeindex.cpp @@ -27,6 +27,9 @@ static QByteArray getByteArray(const QVariant &value) { + if (value.type() == QVariant::DateTime) { + return value.toDateTime().toString().toLatin1(); + } if (value.isValid() && !value.toByteArray().isEmpty()) { return value.toByteArray(); } @@ -82,11 +85,8 @@ template <> void TypeIndex::addProperty(const QByteArray &property) { auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { - const auto date = value.toDateTime(); // Trace() << "Indexing " << mType + ".index." + property << date.toString(); - if (date.isValid()) { - Index(indexName(property), transaction).add(date.toString().toLatin1(), identifier); - } + Index(indexName(property), transaction).add(getByteArray(value), identifier); }; mIndexer.insert(property, indexer); mProperties << property; @@ -123,11 +123,7 @@ void TypeIndex::remove(const QByteArray &identifier, const Sink::ApplicationDoma { for (const auto &property : mProperties) { const auto value = bufferAdaptor.getProperty(property); - // FIXME don't always convert to byte array - const auto data = getByteArray(value); - if (!data.isEmpty()) { - Index(indexName(property), transaction).remove(data, identifier); - } + Index(indexName(property), transaction).remove(getByteArray(value), identifier); } for (auto it = mSortedProperties.constBegin(); it != mSortedProperties.constEnd(); it++) { const auto propertyValue = bufferAdaptor.getProperty(it.key()); -- cgit v1.2.3