changeset 404:3cd39c8cade9 db-protobuf

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Apr 2023 20:52:09 +0200
parents 91124cc8a8c7
children de6de66d70b2
files Resources/Orthanc/Databases/ISqlLookupFormatter.cpp
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/Orthanc/Databases/ISqlLookupFormatter.cpp	Tue Apr 11 11:10:19 2023 +0200
+++ b/Resources/Orthanc/Databases/ISqlLookupFormatter.cpp	Tue Apr 11 20:52:09 2023 +0200
@@ -383,6 +383,8 @@
     }
 
     std::list<std::string> 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 ");