changeset 3079:65e2bfa953ef db-changes

ISqlLookupFormatter::FormatWildcardEscape()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 03 Jan 2019 14:03:39 +0100
parents 147497152ce3
children 1a75595d8e44
files OrthancServer/SQLiteDatabaseWrapper.cpp OrthancServer/Search/ISqlLookupFormatter.cpp OrthancServer/Search/ISqlLookupFormatter.h Plugins/Engine/OrthancPluginDatabase.cpp
diffstat 4 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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<std::string>(level);
     }
 
+    virtual std::string FormatWildcardEscape()
+    {
+      return "ESCAPE '\\'";
+    }
+
     void Bind(SQLite::Statement& statement) const
     {
       size_t pos = 0;
--- 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());
           }
         }
           
--- 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<DatabaseConstraint>& lookup,
--- 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);