From c0bae97a140a39b46472d5aeeb4ed5213365757a Mon Sep 17 00:00:00 2001 From: Isaias Tavares Date: Thu, 5 Nov 2026 01:15:05 -0300 Subject: [PATCH] refactor(db): comment the qualified upsert targets the same way RouteUsageDaily and GoogleApiUsage both qualify the target row's columns in ON CONFLICT ... DO UPDATE, because Postgres reads a bare name there as ambiguous between the target and excluded (42702). Both now carry the same comment above the upsert, and GoogleApiUsage's one-column chain sits on one line like its neighbours. No change to the statements. --- server/src/db/repositories/GoogleApiUsage.repository.ts | 8 +++----- server/src/db/repositories/RouteUsageDaily.repository.ts | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/server/src/db/repositories/GoogleApiUsage.repository.ts b/server/src/db/repositories/GoogleApiUsage.repository.ts index 835fe83da..19720f425 100644 --- a/server/src/db/repositories/GoogleApiUsage.repository.ts +++ b/server/src/db/repositories/GoogleApiUsage.repository.ts @@ -43,11 +43,9 @@ export class GoogleApiUsageRepository extends TrekRepository { await this.kysely() .insertInto('google_api_usage') .values({ day, calls: 1 }) - .onConflict((oc) => - // Qualified: Postgres reads a bare `calls` here as ambiguous between the - // target row and `excluded` (42702); SQLite accepts both spellings. - oc.column('day').doUpdateSet({ calls: (eb) => eb(eb.ref('google_api_usage.calls'), '+', 1) }), - ) + // The target row's column is qualified: Postgres reads a bare name as + // ambiguous between it and `excluded` (42702). + .onConflict((oc) => oc.column('day').doUpdateSet({ calls: (eb) => eb(eb.ref('google_api_usage.calls'), '+', 1) })) .execute(); } diff --git a/server/src/db/repositories/RouteUsageDaily.repository.ts b/server/src/db/repositories/RouteUsageDaily.repository.ts index 38cc7470d..4adaeea9a 100644 --- a/server/src/db/repositories/RouteUsageDaily.repository.ts +++ b/server/src/db/repositories/RouteUsageDaily.repository.ts @@ -80,9 +80,9 @@ export class RouteUsageDailyRepository extends TrekRepository { await this.kysely() .insertInto('route_usage_daily') .values(entry) + // The target row's columns are qualified: Postgres reads a bare name as + // ambiguous between it and `excluded` (42702). .onConflict((oc) => - // The target row's columns are qualified: Postgres reads a bare name - // as ambiguous between it and `excluded` (42702). oc.columns(['day', 'profile', 'surface', 'self_hosted']).doUpdateSet({ requests: (eb) => eb(eb.ref('route_usage_daily.requests'), '+', eb.ref('excluded.requests')), waypoints: (eb) => eb(eb.ref('route_usage_daily.waypoints'), '+', eb.ref('excluded.waypoints')),