# HG changeset patch # User Sebastien Jodogne # Date 1681239043 -7200 # Node ID 261ce0ed85e6b40a731cb90f5038bcf525a4a022 # Parent f783b99e4738e874f9401794ad61595ddf2edc2d fix diff -r f783b99e4738 -r 261ce0ed85e6 OrthancServer/Sources/Database/InstallLabelsTable.sql --- a/OrthancServer/Sources/Database/InstallLabelsTable.sql Tue Apr 11 16:28:28 2023 +0200 +++ b/OrthancServer/Sources/Database/InstallLabelsTable.sql Tue Apr 11 20:50:43 2023 +0200 @@ -19,10 +19,10 @@ CREATE TABLE Labels( - internalId INTEGER REFERENCES Resources(internalId) ON DELETE CASCADE, + id INTEGER REFERENCES Resources(internalId) ON DELETE CASCADE, label TEXT NOT NULL, - PRIMARY KEY(internalId, label) -- Prevents duplicates + PRIMARY KEY(id, label) -- Prevents duplicates ); -CREATE INDEX LabelsIndex1 ON Labels(internalId); +CREATE INDEX LabelsIndex1 ON Labels(id); CREATE INDEX LabelsIndex2 ON Labels(label); -- This index allows efficient lookups diff -r f783b99e4738 -r 261ce0ed85e6 OrthancServer/Sources/Database/PrepareDatabase.sql --- a/OrthancServer/Sources/Database/PrepareDatabase.sql Tue Apr 11 16:28:28 2023 +0200 +++ b/OrthancServer/Sources/Database/PrepareDatabase.sql Tue Apr 11 20:50:43 2023 +0200 @@ -93,9 +93,9 @@ -- New in Orthanc 1.12.0 CREATE TABLE Labels( - internalId INTEGER REFERENCES Resources(internalId) ON DELETE CASCADE, + id INTEGER REFERENCES Resources(internalId) ON DELETE CASCADE, label TEXT NOT NULL, - PRIMARY KEY(internalId, label) -- Prevents duplicates + PRIMARY KEY(id, label) -- Prevents duplicates ); CREATE INDEX ChildrenIndex ON Resources(parentId); @@ -116,7 +116,7 @@ CREATE INDEX ChangesIndex ON Changes(internalId); -- New in Orthanc 1.12.0 -CREATE INDEX LabelsIndex1 ON Labels(internalId); +CREATE INDEX LabelsIndex1 ON Labels(id); CREATE INDEX LabelsIndex2 ON Labels(label); -- This index allows efficient lookups CREATE TRIGGER AttachedFileDeleted diff -r f783b99e4738 -r 261ce0ed85e6 OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp --- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Tue Apr 11 16:28:28 2023 +0200 +++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Tue Apr 11 20:50:43 2023 +0200 @@ -1084,7 +1084,7 @@ } else { - SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT OR IGNORE INTO Labels (internalId, label) VALUES(?, ?)"); + SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT OR IGNORE INTO Labels (id, label) VALUES(?, ?)"); s.BindInt64(0, resource); s.BindString(1, label); s.Run(); @@ -1101,7 +1101,7 @@ } else { - SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM Labels WHERE internalId=? AND label=?"); + SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM Labels WHERE id=? AND label=?"); s.BindInt64(0, resource); s.BindString(1, label); s.Run(); @@ -1115,7 +1115,7 @@ target.clear(); SQLite::Statement s(db_, SQLITE_FROM_HERE, - "SELECT label FROM Labels WHERE internalId=?"); + "SELECT label FROM Labels WHERE id=?"); s.BindInt64(0, resource); while (s.Step()) diff -r f783b99e4738 -r 261ce0ed85e6 OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp Tue Apr 11 16:28:28 2023 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp Tue Apr 11 20:50:43 2023 +0200 @@ -1431,7 +1431,7 @@ "Host that is used for this commands, defaults to `Host` configuration option. " "Allows you to overwrite the destination host for a specific operation.", false) .SetRequestField(KEY_PORT, RestApiCallDocumentation::Type_Number, - "Port that is used for this commands, defaults to `Port` configuration option. " + "Port that is used for this command, defaults to `Port` configuration option. " "Allows you to overwrite the destination port for a specific operation.", false) .SetRequestField(KEY_MOVE_ORIGINATOR_AET, RestApiCallDocumentation::Type_String, "Move originator AET that is used for this commands, in order to fake a C-MOVE SCU", false) diff -r f783b99e4738 -r 261ce0ed85e6 OrthancServer/Sources/Search/ISqlLookupFormatter.cpp --- a/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp Tue Apr 11 16:28:28 2023 +0200 +++ b/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp Tue Apr 11 20:50:43 2023 +0200 @@ -383,6 +383,8 @@ } std::list where; + where.push_back(FormatLevel(queryLevel) + ".resourceType = " + + formatter.FormatResourceType(queryLevel) + comparisons); if (!labels.empty()) { @@ -418,12 +420,9 @@ throw OrthancException(ErrorCode_ParameterOutOfRange); } - where.push_back("(SELECT COUNT(1) FROM Labels WHERE internalId = " + FormatLevel(queryLevel) + - ".internalId AND label IN (" + Join(formattedLabels, "", ", ") + ")) " + condition); + where.push_back("(SELECT COUNT(1) FROM Labels AS selectedLabels WHERE selectedLabels.id = " + FormatLevel(queryLevel) + + ".internalId AND selectedLabels.label IN (" + Join(formattedLabels, "", ", ") + ")) " + condition); } - - where.push_back(FormatLevel(queryLevel) + ".resourceType = " + - formatter.FormatResourceType(queryLevel) + comparisons); sql += joins + Join(where, " WHERE ", " AND ");