mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 19:16:08 +00:00
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.
This commit is contained in:
@@ -43,11 +43,9 @@ export class GoogleApiUsageRepository extends TrekRepository<GoogleApiUsage> {
|
||||
await this.kysely<GoogleApiUsageKyselyDB>()
|
||||
.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();
|
||||
}
|
||||
|
||||
|
||||
@@ -80,9 +80,9 @@ export class RouteUsageDailyRepository extends TrekRepository<RouteUsageDaily> {
|
||||
await this.kysely<RouteUsageDailyKyselyDB>()
|
||||
.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')),
|
||||
|
||||
Reference in New Issue
Block a user