From 2e71390acdacea9cd4f72332b3bafd703425e45c Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 25 Mar 2010 15:59:58 +0000 Subject: [PATCH] Switch from OR to AND in split queries. Fixes issue #116 --- src/librarybackend.cpp | 6 +++--- tests/librarybackend_test.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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")); }