Mercurial > hg > orthanc-databases
changeset 792:048240f671d2
tools/find: filtering against 'LabelsConstraint': 'None' with an empty list of 'Labels' now returns all resources that do not have any labels attached instead of returning all resources
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Thu, 15 Jan 2026 12:37:25 +0100 |
| parents | 7c9283094555 |
| children | 15f949790d84 |
| files | Framework/Plugins/ISqlLookupFormatter.cpp PostgreSQL/NEWS |
| diffstat | 2 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Plugins/ISqlLookupFormatter.cpp Thu Jan 15 12:36:53 2026 +0100 +++ b/Framework/Plugins/ISqlLookupFormatter.cpp Thu Jan 15 12:37:25 2026 +0100 @@ -811,6 +811,10 @@ where.push_back("(SELECT COUNT(1) FROM Labels AS selectedLabels WHERE selectedLabels.id = " + FormatLevel(queryLevel) + ".internalId AND selectedLabels.label IN (" + Join(formattedLabels, "", ", ") + ")) " + condition); } + else if (labelsConstraint == LabelsConstraint_None) // from 1.12.11, 'None' with an empty labels list means "list all resources without any labels" + { + where.push_back("(SELECT COUNT(1) FROM Labels WHERE id = " + FormatLevel(queryLevel) + ".internalId) = 0"); + } sql += joins + Join(where, " WHERE ", " AND "); @@ -1126,6 +1130,10 @@ where.push_back("(SELECT COUNT(1) FROM Labels AS selectedLabels WHERE selectedLabels.id = " + strQueryLevel + ".internalId AND selectedLabels.label IN (" + Join(formattedLabels, "", ", ") + ")) " + condition); } + else if (request.labels_constraint() == LabelsConstraint_None) // from 1.12.11, 'None' with an empty labels list means "list all resources without any labels" + { + where.push_back("(SELECT COUNT(1) FROM Labels WHERE id = " + FormatLevel(queryLevel) + ".internalId) = 0"); + } sql += joins + orderingJoins + Join(where, " WHERE ", " AND "); @@ -1245,6 +1253,11 @@ ") AS temp " " WHERE labelsCount " + condition + ")"); } + else if (labelsConstraint == LabelsConstraint_None) // from 1.12.11, 'None' with an empty labels list means "list all resources without any labels" + { + sql += (" AND (SELECT COUNT(1) FROM Labels WHERE id = internalId) = 0"); + } + if (limit != 0) {
--- a/PostgreSQL/NEWS Thu Jan 15 12:36:53 2026 +0100 +++ b/PostgreSQL/NEWS Thu Jan 15 12:37:25 2026 +0100 @@ -1,3 +1,11 @@ +Pending changes in the mainline +=============================== + +Changes: +* In tools/find, filtering against "LabelsConstraint": "None" with an empty "Labels" list + now returns all resources that do not have any labels attached instead of returning all resources. + + Release 10.0 (2025-12-02) =========================
