Skip to content

fix(reports): occupancy-trend 500 from bad table alias r - #281

Merged
telivity-otaip merged 1 commit into
mainfrom
cursor/occupancy-trend-sql-2642
Aug 4, 2026
Merged

fix(reports): occupancy-trend 500 from bad table alias r#281
telivity-otaip merged 1 commit into
mainfrom
cursor/occupancy-trend-sql-2642

Conversation

@telivity-otaip

Copy link
Copy Markdown
Collaborator

Problem

GET /api/v1/reports/occupancy-trend returned 500 with:
missing FROM-clause entry for table "r"

Staging Reports UI showed Failed to load data when Occupancy Trend was selected.

Fix

Replace hardcoded count(distinct r.id) with count(distinct ${reservations.id}) in:

  • getOccupancyTrend
  • getBookingPace (same bug)

Test plan

  • Deploy image to staging ECS
  • GET /api/v1/reports/occupancy-trend?... returns 200
  • Occupancy Trend chart renders in SPA (paired with haip-cloud unwrapReport fix)
Open in Web Open in Cursor 

Drizzle does not alias reservations as r, so count(distinct r.id)
raised "missing FROM-clause entry for table r" and 500'd the
occupancy-trend (and booking-pace) reports.

Co-authored-by: telivity-otaip <telivity-otaip@users.noreply.github.com>
@telivity-otaip
telivity-otaip marked this pull request as ready for review August 4, 2026 09:14
@telivity-otaip
telivity-otaip merged commit ac3773b into main Aug 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants