fix(db): run every repository statement the Postgres probe reaches

The probe's baseline is empty now: no repository method Postgres refuses,
none it cannot measure.

- reservations.accommodation_id (TEXT) is cast where it is compared with
  day_accommodations.id (INTEGER), in the four reservation reads and the two
  stay reads; SQLite coerced the bare comparison, Postgres refuses it. The
  joined RS18/RR1 read moves to reservation-join.ts beside the repository.
- The usage counters qualify the target row's column in DO UPDATE SET, which
  Postgres reads as ambiguous with `excluded` otherwise.
- ReservationDayPositions.upsertScoped upserts on its primary key instead of
  INSERT OR REPLACE; position is the only other column and nothing references
  the table, so the row left behind is the same.
- PRAGMA wal_checkpoint and VACUUM INTO move from MaintenanceRepository to
  SqliteMaintenance under src/db/engine/sqlite/, the SQLite engine's folder,
  where lint:dialect allows PRAGMA.
- The places list takes category and tag ids as numbers: the service converts
  the query text with toRowId and answers an empty list for one that is no
  id, instead of binding the text to an integer column.
- The probe samples the `present` flag of a partial update's pair as true, so
  the four update methods that sent no SQL are measured, and it now holds
  SQLSTATE class 22 too: a value of the wrong type reaching a column is the
  code's, since the sampler sends what each parameter declares.
This commit is contained in:
Isaias Tavares
2026-11-02 12:48:08 -03:00
parent 14c767a675
commit 62912e5db1
36 changed files with 475 additions and 274 deletions
@@ -47,6 +47,7 @@ export class ThingsRepository {
async record(r: Record<string, number>): Promise<void> {}
async literals(n: bigint, flag: true): Promise<void> {}
async destructured({ id, label }: { id: number; label: string }): Promise<void> {}
async presence(write: { name?: readonly [present: boolean, value: string]; flag?: readonly [boolean, number] }): Promise<void> {}
}
export abstract class AbstractRepository {
async skipped(): Promise<void> {}
@@ -102,6 +103,7 @@ describe('pg-probe argument samples', () => {
'literals',
'nullable',
'optionalCallback',
'presence',
'record',
'rest',
'tuple',
@@ -145,6 +147,13 @@ describe('pg-probe argument samples', () => {
expect(argsOf('collections')).toEqual([new Set([1]), new Map([['1', 1]])]);
});
it('PGPROBE-037: a presence pair is present, so a patch built from it reaches its SQL', () => {
// The repositories' partial updates take `[present: boolean, value]` pairs
// and send nothing when no pair is present; a false flag would leave the
// method unmeasured. Only the element labelled `present` turns true.
expect(argsOf('presence')).toEqual([{ name: [true, 'probe'], flag: [false, 1] }]);
});
it('PGPROBE-035: a required callback makes the method unprobeable, an optional one is left off', () => {
expect(planOf('withCallback')).toMatchObject({ unprobeable: 'fn: a function parameter' });
expect(argsOf('optionalCallback')).toEqual([1]);