# HG changeset patch # User Alain Mazy # Date 1789481975 -7200 # Node ID 7021c0ff2a14a8b4dfd775d8220375991e1cf758 # Parent c7f7f0a6aa5edfcc3ddc770156b87a28e776e3ea Backed out changeset c7f7f0a6aa5e diff -r c7f7f0a6aa5e -r 7021c0ff2a14 OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp --- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Tue Sep 15 11:42:07 2026 +0200 +++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Tue Sep 15 16:19:35 2026 +0200 @@ -622,7 +622,7 @@ " NULL AS c4_string2, " " NULL AS c5_string3, " " NULL AS c6_string4, " - " Lookup.resourceType AS c7_int1, " + " NULL AS c7_int1, " " NULL AS c8_int2, " " NULL AS c9_int3, " " NULL AS c10_big_int1, " @@ -1105,23 +1105,13 @@ // LOG(INFO) << queryId << ": " << internalId; // continue; - // assert(queryId == QUERY_LOOKUP || response.HasResource(internalId)); // the QUERY_LOOKUP must be read first and must create the response before any other query tries to populate the fields - - if (queryId != QUERY_LOOKUP && !response.HasResource(internalId)) // this happens when e.g, accessing an instance level with a series id - { - continue; - } - + assert(queryId == QUERY_LOOKUP || response.HasResource(internalId)); // the QUERY_LOOKUP must be read first and must create the response before any other query tries to populate the fields + switch (queryId) { case QUERY_LOOKUP: - { - int resourceType = s.ColumnInt(C7_INT_1); - if (static_cast(resourceType) == request.GetLevel()) // this happens when e.g, accessing an instance level with a series id - { - response.Add(new FindResponse::Resource(requestLevel, internalId, s.ColumnString(C3_STRING_1))); - } - }; break; + response.Add(new FindResponse::Resource(requestLevel, internalId, s.ColumnString(C3_STRING_1))); + break; case QUERY_LABELS: { diff -r c7f7f0a6aa5e -r 7021c0ff2a14 OrthancServer/Sources/Search/ISqlLookupFormatter.cpp --- a/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp Tue Sep 15 11:42:07 2026 +0200 +++ b/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp Tue Sep 15 16:19:35 2026 +0200 @@ -812,13 +812,11 @@ sql = ("SELECT " + strQueryLevel + ".publicId, " + strQueryLevel + ".internalId, " + - strQueryLevel + ".resourceType, " + ordering + " FROM Resources AS " + strQueryLevel); - std::string joins; //, comparisons - std::vector comparisons; + std::string joins, comparisons; // handle parent constraints if (request.GetOrthancIdentifiers().IsDefined() && request.GetOrthancIdentifiers().DetectLevel() <= queryLevel) @@ -827,11 +825,11 @@ if (topParentLevel == queryLevel) { - comparisons.push_back(FormatLevel(topParentLevel) + ".publicId = " + formatter.GenerateParameter(request.GetOrthancIdentifiers().GetLevel(topParentLevel))); + comparisons += " AND " + FormatLevel(topParentLevel) + ".publicId = " + formatter.GenerateParameter(request.GetOrthancIdentifiers().GetLevel(topParentLevel)); } else { - comparisons.push_back(FormatLevel("parent", topParentLevel) + ".publicId = " + formatter.GenerateParameter(request.GetOrthancIdentifiers().GetLevel(topParentLevel))); + comparisons += " AND " + FormatLevel("parent", topParentLevel) + ".publicId = " + formatter.GenerateParameter(request.GetOrthancIdentifiers().GetLevel(topParentLevel)); for (int level = queryLevel; level > topParentLevel; level--) { @@ -879,7 +877,7 @@ if (!comparison.empty()) { - comparisons.push_back(comparison); + comparisons += " AND " + comparison; } count ++; @@ -898,7 +896,7 @@ if (!comparison.empty()) { - comparisons.push_back(comparison); + comparisons += " AND " + comparison; } count ++; @@ -923,28 +921,9 @@ // } std::list where; - std::string comparisonsStr; - if (comparisons.size() > 0) - { - Orthanc::Toolbox::JoinStrings(comparisonsStr, comparisons, " AND "); - } + where.push_back(strQueryLevel + ".resourceType = " + + formatter.FormatResourceType(queryLevel) + comparisons); - if (request.GetOrthancIdentifiers().IsDefined()) - { - // if there is a filter on the publicId, there is no need to filter on the resourceType. Filtering for resourceType=X AND publicId=Y - // would return the same result as publicId=Y since publicIds are unique. - assert(comparisons.size() > 0); // at least "publicId=Y" - where.push_back(comparisonsStr); - } - else - { - if (comparisonsStr.size() > 0) - { - comparisonsStr = " AND " + comparisonsStr; - } - where.push_back(strQueryLevel + ".resourceType = " + - formatter.FormatResourceType(queryLevel) + comparisonsStr); - } if (!request.GetLabels().empty()) {