changeset 582:8296c6a0238e find-refactoring

ODBC: fixes limit
author Alain Mazy <am@orthanc.team>
date Mon, 21 Oct 2024 17:57:52 +0200
parents a80775ee5eea
children ae7375d38607
files Framework/Plugins/ISqlLookupFormatter.cpp Framework/Plugins/IndexBackend.cpp Odbc/Plugins/OdbcIndex.cpp Odbc/Plugins/OdbcIndex.h TODO
diffstat 5 files changed, 26 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Plugins/ISqlLookupFormatter.cpp	Mon Oct 21 14:34:57 2024 +0200
+++ b/Framework/Plugins/ISqlLookupFormatter.cpp	Mon Oct 21 17:57:52 2024 +0200
@@ -801,7 +801,8 @@
 
     if (limit != 0)
     {
-      sql += " LIMIT " + boost::lexical_cast<std::string>(limit);
+      sql += " ORDER BY " + FormatLevel(queryLevel) + ".publicId ";  // we need an "order by" to use limits
+      sql += formatter.FormatLimits(0, limit);
     }
   }
 
@@ -1192,7 +1193,8 @@
 
     if (limit != 0)
     {
-      sql += " LIMIT " + boost::lexical_cast<std::string>(limit);
+      sql += " ORDER BY publicId ";  // we need an "order by" to use limits
+      sql += formatter.FormatLimits(0, limit);
     }
   }
 }
--- a/Framework/Plugins/IndexBackend.cpp	Mon Oct 21 14:34:57 2024 +0200
+++ b/Framework/Plugins/IndexBackend.cpp	Mon Oct 21 17:57:52 2024 +0200
@@ -2216,7 +2216,7 @@
       {
         case Dialect_MSSQL:
         {
-          if (since > 0)
+          if (count > 0 || since > 0)
           {
             sql += " OFFSET " + boost::lexical_cast<std::string>(since) + " ROWS ";
           }
--- a/Odbc/Plugins/OdbcIndex.cpp	Mon Oct 21 14:34:57 2024 +0200
+++ b/Odbc/Plugins/OdbcIndex.cpp	Mon Oct 21 17:57:52 2024 +0200
@@ -707,20 +707,20 @@
 
 
 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
-  void OdbcIndex::ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
-                              DatabaseManager& manager,
-                              const Orthanc::DatabasePluginMessages::Find_Request& request)
-  {
-    // TODO-FIND
-    throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
-  }
+  // void OdbcIndex::ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
+  //                             DatabaseManager& manager,
+  //                             const Orthanc::DatabasePluginMessages::Find_Request& request)
+  // {
+  //   // TODO-FIND
+  //   throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
+  // }
 
-  void OdbcIndex::ExecuteCount(Orthanc::DatabasePluginMessages::TransactionResponse& response,
-                               DatabaseManager& manager,
-                               const Orthanc::DatabasePluginMessages::Find_Request& request)
-  {
-    // TODO-FIND
-    throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
-  }
+  // void OdbcIndex::ExecuteCount(Orthanc::DatabasePluginMessages::TransactionResponse& response,
+  //                              DatabaseManager& manager,
+  //                              const Orthanc::DatabasePluginMessages::Find_Request& request)
+  // {
+  //   // TODO-FIND
+  //   throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
+  // }
 #endif
 }
--- a/Odbc/Plugins/OdbcIndex.h	Mon Oct 21 14:34:57 2024 +0200
+++ b/Odbc/Plugins/OdbcIndex.h	Mon Oct 21 17:57:52 2024 +0200
@@ -98,13 +98,13 @@
 #endif
 
 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
-    virtual void ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
-                             DatabaseManager& manager,
-                             const Orthanc::DatabasePluginMessages::Find_Request& request) ORTHANC_OVERRIDE;
+    // virtual void ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
+    //                          DatabaseManager& manager,
+    //                          const Orthanc::DatabasePluginMessages::Find_Request& request) ORTHANC_OVERRIDE;
 
-    virtual void ExecuteCount(Orthanc::DatabasePluginMessages::TransactionResponse& response,
-                              DatabaseManager& manager,
-                              const Orthanc::DatabasePluginMessages::Find_Request& request) ORTHANC_OVERRIDE;
+    // virtual void ExecuteCount(Orthanc::DatabasePluginMessages::TransactionResponse& response,
+    //                           DatabaseManager& manager,
+    //                           const Orthanc::DatabasePluginMessages::Find_Request& request) ORTHANC_OVERRIDE;
 #endif
   };
 }
--- a/TODO	Mon Oct 21 14:34:57 2024 +0200
+++ b/TODO	Mon Oct 21 17:57:52 2024 +0200
@@ -76,4 +76,4 @@
 ODBC
 ----
 
-* https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=224
\ No newline at end of file
+* Implement labels
\ No newline at end of file