From 73b72b99ef854b1d1cb07cd4eef9688f84893391 Mon Sep 17 00:00:00 2001 From: rrandomsky Date: Fri, 29 Sep 2023 13:22:47 +0200 Subject: [PATCH] [MOS-471] Fix case sensitive in the note search Changing the search engine in the notes application so that it is not case sensitive. --- module-db/Tables/NotesTable.cpp | 12 +++++++----- pure_changelog.md | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/module-db/Tables/NotesTable.cpp b/module-db/Tables/NotesTable.cpp index 5084d24284652b187af57142b963301f2476172b..d8cf42332af101f13a083dff055ae90f3d49a2e2 100644 --- a/module-db/Tables/NotesTable.cpp +++ b/module-db/Tables/NotesTable.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "NotesTable.hpp" @@ -125,14 +125,16 @@ std::pair, int> NotesTable::getByText(const std::stri unsigned int limit) { - int count = 0; - auto queryRet = db->query("SELECT COUNT(*), INSTR(snippet," str_ ") pos FROM notes WHERE pos > 0;", text.c_str()); + int count = 0; + auto queryRet = + db->query("SELECT COUNT(*), INSTR(LOWER(snippet),LOWER(" str_ ")) pos FROM notes WHERE pos > 0;", text.c_str()); if (queryRet && queryRet->getRowCount() != 0) { count = (*queryRet)[0].getUInt32(); } - std::string queryText = "SELECT *, INSTR(snippet,'" + text + "') pos FROM notes WHERE pos > 0 LIMIT " + - std::to_string(limit) + " offset " + std::to_string(offset) + " ;"; + std::string queryText = "SELECT *, INSTR(LOWER(snippet),LOWER('" + text + + "')) pos FROM notes WHERE pos > 0 LIMIT " + std::to_string(limit) + " offset " + + std::to_string(offset) + " ;"; auto retQuery = db->query(queryText.c_str()); if (retQuery == nullptr || retQuery->getRowCount() == 0) { diff --git a/pure_changelog.md b/pure_changelog.md index ce59ad07f235226090e9c1a72c7e7a2a0eb2232f..6d620ba70870e4a5bc30f24f7693403f39347c58 100644 --- a/pure_changelog.md +++ b/pure_changelog.md @@ -63,6 +63,7 @@ * Fixed missing tethering icon on "Tethering is on" window. * Fixed showing "Copy text" option in empty note. * Fixed "Copy" option missing from the options list in "New message" window. +* Fixed unneeded case sensitiveness in the note search ## [1.7.2 2023-07-28]