changeset 6154:2ee32b4433a5 attach-custom-data

use SQLite::Statement::ColumnBlobAsString() to retrieve blob columns
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Jun 2025 16:34:30 +0200
parents 92c5ad130204
children 18fc493db0d2
files OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp
diffstat 1 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Mon Jun 02 16:24:29 2025 +0200
+++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Mon Jun 02 16:34:30 2025 +0200
@@ -2176,8 +2176,14 @@
       }
       else
       {
-        value = s.ColumnString(0);
-        return true;
+        if (!s.ColumnBlobAsString(0, &value))
+        {
+          throw OrthancException(ErrorCode_NotEnoughMemory);
+        }
+        else
+        {
+          return true;
+        }
       }    
     }
 
@@ -2213,8 +2219,14 @@
 
       while (statement->Step())
       {
+        std::string value;
+        if (!statement->ColumnBlobAsString(1, &value))
+        {
+          throw OrthancException(ErrorCode_NotEnoughMemory);
+        }
+
         keys.push_back(statement->ColumnString(0));
-        values.push_back(statement->ColumnString(1));
+        values.push_back(value);
       }
     }
 
@@ -2267,7 +2279,11 @@
       else
       {
         rowId = s->ColumnInt64(0);
-        value = s->ColumnString(1);
+
+        if (!s->ColumnBlobAsString(1, &value))
+        {
+          throw OrthancException(ErrorCode_NotEnoughMemory);
+        }
 
         SQLite::Statement s2(db_, SQLITE_FROM_HERE,
                             "DELETE FROM Queues WHERE id = ?");