# HG changeset patch # User Sebastien Jodogne # Date 1546520619 -3600 # Node ID 65e2bfa953efa23ea43b7e34a5814083ea22bbee # Parent 147497152ce3d706530bb09e6cafae1b5c513823 ISqlLookupFormatter::FormatWildcardEscape() diff -r 147497152ce3 -r 65e2bfa953ef OrthancServer/SQLiteDatabaseWrapper.cpp --- a/OrthancServer/SQLiteDatabaseWrapper.cpp Thu Jan 03 12:47:17 2019 +0100 +++ b/OrthancServer/SQLiteDatabaseWrapper.cpp Thu Jan 03 14:03:39 2019 +0100 @@ -1137,6 +1137,11 @@ return boost::lexical_cast(level); } + virtual std::string FormatWildcardEscape() + { + return "ESCAPE '\\'"; + } + void Bind(SQLite::Statement& statement) const { size_t pos = 0; diff -r 147497152ce3 -r 65e2bfa953ef OrthancServer/Search/ISqlLookupFormatter.cpp --- a/OrthancServer/Search/ISqlLookupFormatter.cpp Thu Jan 03 12:47:17 2019 +0100 +++ b/OrthancServer/Search/ISqlLookupFormatter.cpp Thu Jan 03 14:03:39 2019 +0100 @@ -190,11 +190,13 @@ if (constraint.IsCaseSensitive()) { - comparison = tag + ".value LIKE " + parameter + " ESCAPE '\\'"; + comparison = (tag + ".value LIKE " + parameter + " " + + formatter.FormatWildcardEscape()); } else { - comparison = "lower(" + tag + ".value) LIKE lower(" + parameter + ") ESCAPE '\\'"; + comparison = ("lower(" + tag + ".value) LIKE lower(" + + parameter + ") " + formatter.FormatWildcardEscape()); } } diff -r 147497152ce3 -r 65e2bfa953ef OrthancServer/Search/ISqlLookupFormatter.h --- a/OrthancServer/Search/ISqlLookupFormatter.h Thu Jan 03 12:47:17 2019 +0100 +++ b/OrthancServer/Search/ISqlLookupFormatter.h Thu Jan 03 14:03:39 2019 +0100 @@ -49,6 +49,8 @@ virtual std::string FormatResourceType(ResourceType level) = 0; + virtual std::string FormatWildcardEscape() = 0; + static void Apply(std::string& sql, ISqlLookupFormatter& formatter, const std::vector& lookup, diff -r 147497152ce3 -r 65e2bfa953ef Plugins/Engine/OrthancPluginDatabase.cpp --- a/Plugins/Engine/OrthancPluginDatabase.cpp Thu Jan 03 12:47:17 2019 +0100 +++ b/Plugins/Engine/OrthancPluginDatabase.cpp Thu Jan 03 14:03:39 2019 +0100 @@ -1114,8 +1114,6 @@ throw OrthancException(ErrorCode_DatabasePlugin); } - printf(" ++ [%s]\n", match.resourceId); - assert(answerMatchingResources_ != NULL); answerMatchingResources_->push_back(match.resourceId);