diff --git a/src/librarybackend.cpp b/src/librarybackend.cpp index caf7be3a9..519a9d539 100644 --- a/src/librarybackend.cpp +++ b/src/librarybackend.cpp @@ -111,11 +111,11 @@ bool LibraryBackend::Like(const char* needle, const char* haystack) { } QString b = QString::fromUtf8(haystack); foreach (const QString& query, query_cache_) { - if (b.contains(query, Qt::CaseInsensitive)) { - return true; + if (!b.contains(query, Qt::CaseInsensitive)) { + return false; } } - return false; + return true; } // Custom LIKE(X, Y) function for sqlite3 that supports case insensitive unicode matching. diff --git a/tests/librarybackend_test.cpp b/tests/librarybackend_test.cpp index 4d94238a1..c11014e46 100644 --- a/tests/librarybackend_test.cpp +++ b/tests/librarybackend_test.cpp @@ -224,8 +224,8 @@ TEST_F(LibraryBackendTest, LikeCacheInvalidated) { TEST_F(LibraryBackendTest, LikeQuerySplit) { EXPECT_TRUE(backend_->Like("%foo bar%", "foobar")); - EXPECT_TRUE(backend_->Like("%foo bar%", "barbaz")); - EXPECT_TRUE(backend_->Like("%foo bar%", "foobaz")); + EXPECT_FALSE(backend_->Like("%foo bar%", "barbaz")); + EXPECT_FALSE(backend_->Like("%foo bar%", "foobaz")); EXPECT_FALSE(backend_->Like("%foo bar%", "baz")); }