fix: use postgres arrays and normalized idempotency comparison

This commit is contained in:
2026-09-07 18:02:38 +02:00
parent 906fe9ac37
commit 3ccdcf0cf6
@@ -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 *`;