From 3ccdcf0cf69be342ad12b726e2558a56cac2c57f Mon Sep 17 00:00:00 2001 From: Simon Axelsson Date: Mon, 7 Sep 2026 18:02:38 +0200 Subject: [PATCH] fix: use postgres arrays and normalized idempotency comparison --- src/repositories/dataset-version-repository.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/repositories/dataset-version-repository.ts b/src/repositories/dataset-version-repository.ts index 865c61c..bd3f43d 100644 --- a/src/repositories/dataset-version-repository.ts +++ b/src/repositories/dataset-version-repository.ts @@ -40,12 +40,16 @@ function toVersion(row: VersionRow): DatasetVersion { }; } +function normalizedCount(value: string | number | null | undefined): number | undefined { + return value == null ? undefined : Number(value); +} + function sameInput(row: VersionRow | DatasetVersion, input: CreateDatasetVersionInput): boolean { return row.dataset_id === input.dataset_id && row.tenant_id === input.tenant_id && row.project_id === input.project_id && row.schema_version === input.schema_version - && (row.record_count ?? undefined) === (input.record_count ?? undefined) + && normalizedCount(row.record_count) === normalizedCount(input.record_count) && (row.description ?? undefined) === (input.description ?? undefined) && row.created_by === input.created_by && JSON.stringify(row.artifact_refs) === JSON.stringify(input.artifact_refs); @@ -139,7 +143,7 @@ export class PostgresDatasetVersionRepository implements DatasetVersionRepositor correlation_id, idempotency_key) VALUES (${input.dataset_id}, ${version}, ${input.tenant_id}, ${input.project_id}, - ${input.artifact_refs}, ${input.schema_version}, ${input.record_count ?? null}, + ${tx.array(input.artifact_refs)}, ${input.schema_version}, ${input.record_count ?? null}, ${input.description ?? null}, ${input.created_by}, ${input.correlation_id ?? null}, ${input.idempotency_key ?? null}) RETURNING *`;