Add effectiveLocation.name to GET /holdings-storage/holdings?query=… search result

Description

Regarding = https://github.com/folio-org/mod-inventory-storage/pull/1128/files, copied from https://github.com/folio-org/ui-inventory/pull/2720#issuecomment-2630771429 :

I appreciate the pointer to the documentation, but, ugh, strongly object the unusualness of the behavior in this API. I understand that it functions correctly and that is documented, but given the template-like nature of the documentation for fields like offset, limit, and query in RMB-based modules, I never looked at the documentation for query because I expected it to be the same as for every other module, and furthermore because you usually sort a result-set by a field present in the result-set, so I looked at the list of fields.

Presumably you're doing the join (otherwise how could you sort by that field?) so just do the conventional thing and include effectiveLocation { name } in the result set. Then you don't even have to document it because it's just the normal, expected behavior.

Environment

None

Potential Workaround

None

Checklist

hide

Activity

Show:

Julian Ladisch February 4, 2025 at 5:35 PM

mod-inventory APIs can add the location name to the result set, but usually they cannot sort on the location name because mod-inventory passes the request to mod-inventory-storage and sorting is handled by mod-inventory-storage. mod-inventory APIs can sort by location name if all records (ignoring offset and limit) are loaded into mod-inventory’s memory and sorted in memory. There can be millions of matching holdings records.

Zak Burke February 3, 2025 at 2:45 PM

This is an interesting, fascinating, and thorough technical explanation of “why this API performs in unexpected ways”. Thank you, ! But the unexpectedness of this API remains, and IMO that is the real problem here. You have solved a problem by flouting convention, and thus created another problem as a knock-on effect.

In fact, the UI does display the location-name, so probably the best approach is to follow the advice in the description and use mod-inventory or mod-search APIs to retrieve the necessary fields in a predictable fashion. I do not generally work in ui-inventory, that’s Folijet’s domain, so I will let (their tech lead) decide if the friction from this API is bothersome enough to open a ticket there to use a different API, or just handle the sort client-side.

I’m fine closing this as “Won’t do”, but I appreciate you taking the time and effort to explain the situation.

Julian Ladisch February 3, 2025 at 2:12 PM

We do not join the holdings table and the location table unconditionally to get the best performance.

Use mod-inventory APIs or mod-search APIs if you need the location name in the result set.

RMB only partially supports table joins:

https://github.com/folio-org/raml-module-builder?tab=readme-ov-file#cql2pgjson-foreign-key-cross-table-index-queries

CQL doesn’t support the join condition (the SQL ON clause), and joins may result in full table scans and should be avoided in most cases.

Therefore most joins require hand-written SQL and doesn’t support all queries but only a specific use case that is known not to result in a table scan. One example is .

It requires a rewrite of RMB’s CQL implementation if the location name should be supported in the query and returned in the result set; this requires too much development work. Therefore I suggest to close this as “Won’t do”.

Details

Assignee

Reporter

Priority

Development Team

TestRail: Cases

Open TestRail: Cases

TestRail: Runs

Open TestRail: Runs

Created February 3, 2025 at 1:57 PM
Updated February 4, 2025 at 5:35 PM
TestRail: Cases
TestRail: Runs