# HG changeset patch # User Alain Mazy # Date 1736345913 -3600 # Node ID a9316631f2daa299b1a7cf574571709948892587 # Parent 78ed0f5389cc6d0d5b1104849b3aa750bd070062 tools/find: fix query by ModalitiesInStudy with pagination diff -r 78ed0f5389cc -r a9316631f2da Framework/Plugins/ISqlLookupFormatter.cpp --- a/Framework/Plugins/ISqlLookupFormatter.cpp Fri Jan 03 10:46:22 2025 +0100 +++ b/Framework/Plugins/ISqlLookupFormatter.cpp Wed Jan 08 15:18:33 2025 +0100 @@ -1023,7 +1023,25 @@ { std::string join; FormatJoin(join, constraint, count); - joins += join; + + + if (constraint.GetLevel() <= queryLevel) + { + joins += join; + } + else if (constraint.GetLevel() == queryLevel + 1 && !comparison.empty()) + { + // new in v 1.12.6, the constraints on child tags are actually looking for one child with this value + comparison = " EXISTS (SELECT 1 FROM Resources AS " + FormatLevel(static_cast(queryLevel + 1)) + + join + + " WHERE " + comparison + " AND " + + FormatLevel(static_cast(queryLevel + 1)) + ".parentId = " + FormatLevel(static_cast(queryLevel)) + ".internalId) "; + } + + if (!comparison.empty()) + { + comparisons += " AND " + comparison; + } if (!comparison.empty()) { @@ -1062,13 +1080,14 @@ FormatLevel(static_cast(level + 1)) + ".parentId"); } - for (int level = queryLevel + 1; level <= lowerLevel; level++) - { - sql += (" INNER JOIN Resources " + - FormatLevel(static_cast(level)) + " ON " + - FormatLevel(static_cast(level - 1)) + ".internalId=" + - FormatLevel(static_cast(level)) + ".parentId"); - } + // disabled in v 1.12.6 now that the child levels are considered as "is there at least one child that meets this constraint" + // for (int level = queryLevel + 1; level <= lowerLevel; level++) + // { + // sql += (" INNER JOIN Resources " + + // FormatLevel(static_cast(level)) + " ON " + + // FormatLevel(static_cast(level - 1)) + ".internalId=" + + // FormatLevel(static_cast(level)) + ".parentId"); + // } std::list where; where.push_back(strQueryLevel + ".resourceType = " + diff -r 78ed0f5389cc -r a9316631f2da PostgreSQL/NEWS --- a/PostgreSQL/NEWS Fri Jan 03 10:46:22 2025 +0100 +++ b/PostgreSQL/NEWS Wed Jan 08 15:18:33 2025 +0100 @@ -12,6 +12,9 @@ * Disable DB Housekeeping thread on ReadOnly systems. +* Find: Implemented support for searching for child resources fulfilling + a dicom tag constraint. This solves the search against ModalitiesInStudy + that was broken when used with pagination. Release 7.0 (2024-12-18)