feat(queries): cast catalogNumber only if it is numeric
#7469
+5
−1
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.

Fixes #7468
Possibly fixes #1710
There is an issue where catalog numbers shown in other collections via the Collection Relationship mechanism are still cast to integers, resulting in the catalog number displaying as
0instead of the original value. These non-numeric catalog numbers should not be cast to ensure the correct value is shown. If it is an number, it should still be cast to preserve existing behavior.In this PR, catalog numbers are now conditionally cast to
Numeric(65)only if they match a numeric pattern (using a regex check for integers or decimals). Non-numeric strings like'F-235694'are left as strings.casestatement with a regex check before casting the catalog number if it is a numeric catalog number format.^-?[0-9]+(\.[0-9]+)?$matches optional negative sign, digits, and optional decimal part.'123'or'123.45'), it's cast toNumeric(65)like before.'F-235694'), it's left as a string.Screenshots
Current behavior:

Desired behavior:

Checklist
self-explanatory (or properly documented)
Testing instructions
CatalogNumberNumericformat to one with a string000000000)In my example, the related catalog number is
F-235694, but when cast, this becomes0. This is shown in the query results as000000000.Cat # Issue.json