From 8f9f14a88188655f5ca982d23b3087fb27b56bac Mon Sep 17 00:00:00 2001 From: Steve Pieper Date: Mon, 13 Nov 2023 19:31:23 -0500 Subject: [PATCH] BUG: Fix dicom db insert with URL field We should be checking the return value of QSqlQuery::exec to catch problems. Filed an issue to track this: https://github.com/commontk/CTK/issues/1155 --- Libs/DICOM/Core/ctkDICOMDatabase.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Libs/DICOM/Core/ctkDICOMDatabase.cpp b/Libs/DICOM/Core/ctkDICOMDatabase.cpp index 0189099f27..799b7862df 100644 --- a/Libs/DICOM/Core/ctkDICOMDatabase.cpp +++ b/Libs/DICOM/Core/ctkDICOMDatabase.cpp @@ -965,9 +965,10 @@ void ctkDICOMDatabasePrivate::insert(const ctkDICOMItem& dataset, const QString& } QSqlQuery insertImageStatement(Database); - insertImageStatement.prepare("INSERT INTO Images ( 'SOPInstanceUID', 'Filename', 'URL', 'SeriesInstanceUID', 'InsertTimestamp' ) VALUES ( ?, ?, NULL, ?, ? )"); + insertImageStatement.prepare("INSERT INTO Images ( 'SOPInstanceUID', 'Filename', 'URL', 'SeriesInstanceUID', 'InsertTimestamp' ) VALUES ( ?, ?, ?, ?, ? )"); insertImageStatement.addBindValue(sopInstanceUID); insertImageStatement.addBindValue(storedFilePathInDatabase); + insertImageStatement.addBindValue(QString("")); insertImageStatement.addBindValue(seriesInstanceUID); insertImageStatement.addBindValue(QDateTime::currentDateTime()); insertImageStatement.exec(); @@ -1112,9 +1113,10 @@ void ctkDICOMDatabase::insert(const QList& ind // Insert image files QSqlQuery insertImageStatement(d->Database); - insertImageStatement.prepare("INSERT INTO Images ( 'SOPInstanceUID', 'Filename', 'URL', 'SeriesInstanceUID', 'InsertTimestamp' ) VALUES ( ?, ?, NULL, ?, ? )"); + insertImageStatement.prepare("INSERT INTO Images ( 'SOPInstanceUID', 'Filename', 'URL', 'SeriesInstanceUID', 'InsertTimestamp' ) VALUES ( ?, ?, ?, ?, ? )"); insertImageStatement.addBindValue(sopInstanceUID); insertImageStatement.addBindValue(d->internalPathFromAbsolute(storedFilePath)); + insertImageStatement.addBindValue(QString("")); insertImageStatement.addBindValue(seriesInstanceUID); insertImageStatement.addBindValue(QDateTime::currentDateTime()); insertImageStatement.exec();