Mercurial > hg > orthanc-databases
changeset 399:19bd3ee1f0b3 db-protobuf
support for labels in sqlite
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Apr 2023 15:28:47 +0200 |
parents | 8dedfd982b83 |
children | 897253c21208 |
files | Framework/Plugins/IndexBackend.cpp SQLite/Plugins/SQLiteIndex.cpp SQLite/Plugins/SQLiteIndex.h |
diffstat | 3 files changed, 24 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Plugins/IndexBackend.cpp Thu Apr 06 19:09:51 2023 +0200 +++ b/Framework/Plugins/IndexBackend.cpp Fri Apr 07 15:28:47 2023 +0200 @@ -2626,6 +2626,12 @@ "INSERT INTO Labels VALUES(${id}, ${label}) ON CONFLICT DO NOTHING")); break; + case Dialect_SQLite: + statement.reset(new DatabaseManager::CachedStatement( + STATEMENT_FROM_HERE, manager, + "INSERT OR IGNORE INTO Labels VALUES(${id}, ${label})")); + break; + default: throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); }
--- a/SQLite/Plugins/SQLiteIndex.cpp Thu Apr 06 19:09:51 2023 +0200 +++ b/SQLite/Plugins/SQLiteIndex.cpp Fri Apr 07 15:28:47 2023 +0200 @@ -166,6 +166,23 @@ t.Commit(); } + + { + DatabaseManager::Transaction t(manager, TransactionType_ReadWrite); + + if (!t.GetDatabaseTransaction().DoesTableExist("Labels")) + { + t.GetDatabaseTransaction().ExecuteMultiLines( + "CREATE TABLE Labels(" + " id INTEGER REFERENCES Resources(internalId) ON DELETE CASCADE," + " label TEXT NOT NULL," + " PRIMARY KEY(id, label));" + "CREATE INDEX LabelsIndex1 ON Labels(id);" + "CREATE INDEX LabelsIndex2 ON Labels(label);"); + } + + t.Commit(); + } }