location catalog query isn't right - its not returning results it should
Open
@MikeNeilson is already working on this.
Since Jan 30, 2026.
priority:high
- Dominant language
- Java
- Stars
- 28
- Forks
- 25
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 20
Description
In testing https://github.com/USACE/cwms-data-api/issues/454 I'm seeing weird results from the location catalog end-point.
Its returning things like:
{
"total": 3354,
"entries": [],
"page-size": 500
}
Meaning the query that calculates the total doesn't agree with the query that finds the entries - weird.
Printing out the query:
with "limiter"("real_id", "location_code") as (select "real_id", "real_code"
from (select "CWMS_20"."AV_LOC2"."LOCATION_ID" "real_id",
"CWMS_20"."AV_LOC2"."LOCATION_CODE" "real_code"
from "CWMS_20"."AV_LOC2"
where ((regexp_like("CWMS_20"."AV_LOC2"."LOCATION_ID", '.*', 'i')) and
"CWMS_20"."AV_LOC2"."LOCATION_CODE" <> 0 and
lower("CWMS_20"."AV_LOC2"."UNIT_SYSTEM") = lower('SI') and
upper("CWMS_20"."AV_LOC2"."DB_OFFICE_ID") = 'SPK' and
(regexp_like("CWMS_20"."AV_LOC2"."LOC_ALIAS_CATEGORY", 'Agency Aliases', 'i')) and
upper("CWMS_20"."AV_LOC2"."LOCATION_ID") > '*' and
"CWMS_20"."AV_LOC2"."ALIASED_ITEM" is null)
order by "CWMS_20"."AV_LOC2"."DB_OFFICE_ID" asc,
"CWMS_20"."AV_LOC2"."LOCATION_ID" asc) "data"
where rownum <= 500)
select "limiter"."real_id", "CWMS_20"."AV_LOC2"."LOCATION_ID" "alias_id", "CWMS_20"."AV_LOC2".*
from "limiter"
left outer join "CWMS_20"."AV_LOC2" on "CWMS_20"."AV_LOC2"."LOCATION_CODE" = "limiter"."location_code"
order by "CWMS_20"."AV_LOC2"."DB_OFFICE_ID" asc, "limiter"."real_id" asc, "CWMS_20"."AV_LOC2"."ALIASED_ITEM" asc
I think that inner "ALIASED_ITEM is null" isn't in the right spot. I think it needs to be added to a new where after the final left outer join.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.