Skip to content

Commit

Permalink
BUG: Fix dicom db insert with URL field
Browse files Browse the repository at this point in the history
We should be checking the return value of QSqlQuery::exec
to catch problems.

Filed an issue to track this:

commontk#1155
  • Loading branch information
pieper committed Nov 14, 2023
1 parent 5200de9 commit 8f9f14a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Libs/DICOM/Core/ctkDICOMDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -1112,9 +1113,10 @@ void ctkDICOMDatabase::insert(const QList<ctkDICOMDatabase::IndexingResult>& 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();
Expand Down

0 comments on commit 8f9f14a

Please sign in to comment.