UIEUS-493: Add reportReleases to MCL#609
Merged
Merged
Conversation
alb3rtino
approved these changes
Feb 23, 2026
Contributor
alb3rtino
left a comment
There was a problem hiding this comment.
From the test fixtures, sorting appears to depend on reportReleases being pre-sorted. I opened https://folio-org.atlassian.net/browse/MODEUS-219 to make sure it is.
Contributor
|
Consider adding |
Contributor
|
|
|
alb3rtino
added a commit
to folio-org/mod-erm-usage
that referenced
this pull request
Mar 11, 2026
…ng (#214) https://folio-org.atlassian.net/browse/MODEUS-219 ## Purpose The `udp_report_releases` SQL function returns the `reportReleases` array in unspecified order. The function uses `jsonb_agg(DISTINCT ...)` with an `ORDER BY` clause at the query level, but since the query returns a single aggregated row, the `ORDER BY` has no effect on the array element ordering. The PostgreSQL documentation states: > The aggregate functions array_agg, json_agg, jsonb_agg, [...] produce meaningfully different result values depending on the order of the input values. This ordering is unspecified by default, but can be controlled by writing an ORDER BY clause within the aggregate call. The [documentation on aggregate expressions](https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-AGGREGATES) further clarifies that `DISTINCT` alone does not guarantee ordering - it only ensures each distinct value is processed once. To control ordering, an `ORDER BY` clause must be placed within the aggregate call itself: ```sql aggregate_name (DISTINCT expression [ , ... ] [ order_by_clause ] ) ``` The existing tests in `SQLTriggersIT` assert sorted order and currently pass, but only by coincidence - PostgreSQL's `DISTINCT` implementation happens to use sort-based deduplication, which is not a documented guarantee. ## Approach Refactor `udp_report_releases` to use a subquery pattern, matching the approach already used by `udp_report_types` and `udp_report_errors` in the same file. This moves `DISTINCT` and `ORDER BY` into a subquery so that sorting occurs before aggregation, making the ordering explicit and reliable. An alternative would be to use the inline `ORDER BY` within the aggregate call: ```sql SELECT COALESCE(jsonb_agg(DISTINCT jsonb->>'release' ORDER BY jsonb->>'release'), '[]'::jsonb) ``` The subquery approach was chosen for consistency with the other functions in the same file. ## Related folio-org/ui-erm-usage#609
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



https://folio-org.atlassian.net/browse/UIEUS-493
Add "Report releases" to
MultiColumnListin SASQ.As a user, I would like to have an additional column Report releases in the provider list so that I can see which report releases of Counter reports are available within a UDP record right in the list.
The available report releases should be listed in the table cell, sorted by version number. When I want to sort the column, the entire contents of the table cell are sorted.
Use Case
Users create multiple UDPs for providers in order to have a record for each Counter release. When users search for a provider in the provider list, they want to be able to see within the provider list which report releases are available within the UDP record in addition of using the filter.
Concept
eUsage > Provider list
Adding an additional column Report releases.
Acceptance criterias (UAT)