@iterativeflow/mysql 2.0.0-alpha.3 → 2.0.0-alpha.5

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.
Files changed (2) hide show
  1. package/dist/index.mjs +10 -0
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -390,6 +390,16 @@ const createMysqlStore = (sql, t, id) => {
390
390
  checkpointStep(c, fx) {
391
391
  return sql.tx(async (tx) => {
392
392
  if (!(await tx.query(`SELECT 1 AS ok FROM ${t.run} WHERE id = ?`, [c.runId]))[0]) throw new Error(`checkpointStep: run ${c.runId} not found`);
393
+ if (fx?.requireVersion !== void 0) {
394
+ if ((await tx.query(`SELECT 1 AS ok FROM ${t.step} WHERE run_id = ? AND cursor_key = ?`, [c.runId, c.cursorKey])).length === 0) {
395
+ const job = await tx.query(`SELECT version FROM ${t.job} WHERE run_id = ? FOR UPDATE`, [c.runId]);
396
+ if (!job[0] || Number(job[0].version) !== fx.requireVersion) return {
397
+ status: c.status,
398
+ attempts: c.attempts,
399
+ committed: false
400
+ };
401
+ }
402
+ }
393
403
  if ((await tx.exec(`INSERT IGNORE INTO ${t.step} (run_id, cursor_key, status, result, error, attempts, shape)
394
404
  VALUES (?, ?, ?, ?, ?, ?, ?)`, [
395
405
  c.runId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iterativeflow/mysql",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.5",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,7 +28,7 @@
28
28
  "build": "tsdown"
29
29
  },
30
30
  "dependencies": {
31
- "@iterativeflow/core": "2.0.0-alpha.3"
31
+ "@iterativeflow/core": "2.0.0-alpha.5"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "mysql2": ">=3.0.0"