Skip to content

Commit ea130a5

Browse files
howethomasclaude
andcommitted
fix: qualify created_at with table alias in getGrowthTrends join query
The monthly_stats CTE joined vcons, dialog, and attachments — all three have a created_at column. The unqualified DATE_TRUNC('month', created_at) caused 42702: column reference "created_at" is ambiguous. Fixed to v.created_at. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent 8da93c4 commit ea130a5

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/db/database-analytics.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,8 @@ export class SupabaseDatabaseAnalytics implements IDatabaseAnalytics {
419419
private async getGrowthTrends(monthsBack: number) {
420420
const query = `
421421
WITH monthly_stats AS (
422-
SELECT
423-
DATE_TRUNC('month', created_at) as month,
422+
SELECT
423+
DATE_TRUNC('month', v.created_at) as month,
424424
COUNT(*) as vcon_count,
425425
COUNT(DISTINCT v.id) as unique_vcons,
426426
SUM(COALESCE(d.size_bytes, 0)) as dialog_size,
@@ -431,7 +431,7 @@ export class SupabaseDatabaseAnalytics implements IDatabaseAnalytics {
431431
LEFT JOIN dialog d ON d.vcon_id = v.id
432432
LEFT JOIN attachments a ON a.vcon_id = v.id
433433
WHERE v.created_at >= NOW() - INTERVAL '${monthsBack} months'
434-
GROUP BY DATE_TRUNC('month', created_at)
434+
GROUP BY DATE_TRUNC('month', v.created_at)
435435
ORDER BY month
436436
)
437437
SELECT

0 commit comments

Comments
 (0)