@dudousxd/nestjs-durable-store-drizzle 0.24.5 → 0.24.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pg/index.cjs CHANGED
@@ -482,6 +482,11 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
482
482
  });
483
483
  }
484
484
  async createRun(run) {
485
+ if ((0, import_nestjs_durable_core.normalizeAttributeRows)(run.id, run.searchAttributes).length === 0) {
486
+ await this.db.insert(durableWorkflowRuns).values(toRunRow(run));
487
+ await this.db.delete(durableRunAttributes).where((0, import_drizzle_orm4.eq)(durableRunAttributes.runId, run.id));
488
+ return;
489
+ }
485
490
  await this.db.transaction(async (tx) => {
486
491
  await tx.insert(durableWorkflowRuns).values(toRunRow(run));
487
492
  await reindexAttributes(tx, run.id, run.searchAttributes);
@@ -492,6 +497,10 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
492
497
  const row = toRunPatch(patch);
493
498
  const reindex = "searchAttributes" in patch;
494
499
  if (!Object.keys(row).length && !reindex) return;
500
+ if (!reindex) {
501
+ await this.db.update(durableWorkflowRuns).set(row).where((0, import_drizzle_orm4.eq)(durableWorkflowRuns.id, runId));
502
+ return;
503
+ }
495
504
  await this.db.transaction(async (tx) => {
496
505
  if (Object.keys(row).length) await tx.update(durableWorkflowRuns).set(row).where((0, import_drizzle_orm4.eq)(durableWorkflowRuns.id, runId));
497
506
  if (reindex) await reindexAttributes(tx, runId, patch.searchAttributes);