changeset 5762:d52b3f394f69 find-refactoring

FormatLimits (SQLServer needs custom code)
author Alain Mazy <am@orthanc.team>
date Fri, 06 Sep 2024 16:04:18 +0200
parents 0b44920843b5
children 1b0e67be3c15
files OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp OrthancServer/Sources/Search/ISqlLookupFormatter.cpp OrthancServer/Sources/Search/ISqlLookupFormatter.h
diffstat 3 files changed, 18 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Fri Sep 06 15:21:54 2024 +0200
+++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Fri Sep 06 16:04:18 2024 +0200
@@ -65,6 +65,21 @@
       return "ESCAPE '\\'";
     }
 
+    virtual std::string FormatLimits(uint64_t since, uint64_t count) ORTHANC_OVERRIDE
+    {
+      std::string sql;
+      if (count > 0)
+      {
+        sql += " LIMIT " + boost::lexical_cast<std::string>(count);
+      }
+      if (since > 0)
+      {
+        sql += " OFFSET " + boost::lexical_cast<std::string>(since);
+      }
+      
+      return sql;
+    }
+
     virtual bool IsEscapeBrackets() const ORTHANC_OVERRIDE
     {
       return false;
--- a/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp	Fri Sep 06 15:21:54 2024 +0200
+++ b/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp	Fri Sep 06 16:04:18 2024 +0200
@@ -752,14 +752,7 @@
 
     if (request.HasLimits())
     {
-      if (request.GetLimitsCount() > 0)
-      {
-        sql += " LIMIT " + boost::lexical_cast<std::string>(request.GetLimitsCount());
-      }
-      if (request.GetLimitsSince() > 0)
-      {
-        sql += " OFFSET " + boost::lexical_cast<std::string>(request.GetLimitsSince());
-      }
+      sql += formatter.FormatLimits(request.GetLimitsSince(), request.GetLimitsCount());
     }
 
   }
--- a/OrthancServer/Sources/Search/ISqlLookupFormatter.h	Fri Sep 06 15:21:54 2024 +0200
+++ b/OrthancServer/Sources/Search/ISqlLookupFormatter.h	Fri Sep 06 16:04:18 2024 +0200
@@ -58,6 +58,8 @@
 
     virtual std::string FormatWildcardEscape() = 0;
 
+    virtual std::string FormatLimits(uint64_t since, uint64_t count) = 0;
+
     /**
      * Whether to escape '[' and ']', which is only needed for
      * MSSQL. New in Orthanc 1.10.0, from the following changeset: