@voltro/sql-mysql 0.20.2 → 0.22.0
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/CHANGELOG.md +398 -0
- package/THIRD-PARTY-NOTICES.md +4 -4
- package/dist/index.d.ts +14 -0
- package/dist/index.js +194 -182
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -3,16 +3,16 @@ import { Config as t, Effect as n, Layer as r, ManagedRuntime as i, Option as a,
|
|
|
3
3
|
import { EventEmitter as c } from "node:events";
|
|
4
4
|
import { createLogger as l } from "@voltro/logger";
|
|
5
5
|
import { SqlClient as u, TransactionConnection as d } from "@effect/sql/SqlClient";
|
|
6
|
-
import { CDC_OFFSETS_TABLE as f, EagerCardinalityError as p, _voltroCdcOffsetsTable as m, attachEagerLoads as h, attributionFields as g, attributionKey as _,
|
|
6
|
+
import { CDC_OFFSETS_TABLE as f, EagerCardinalityError as p, _voltroCdcOffsetsTable as m, attachEagerLoads as h, attributionFields as g, attributionKey as _, beginLocalWrite as v, compileEagerJson as y, compilePredicate as b, compileRawFragment as x, compileSelect as S, currentWriteAttribution as C, decodeRowsFromSchema as w, encodeRowForSchema as T, endLocalWrite as E, hasEagerLoads as D, isTableReactive as O, qualifyTable as ee, raiseChangeListenerCeiling as te, recordsTable as ne, registerPendingAttribution as re, requireTable as k, resolveEchoAttribution as A, runWithWriteAttribution as ie, runWriteRecorders as ae, settleTransactionExit as oe, stampGeneratedId as j, stampGeneratedIds as se, withCapturedAttribution as M } from "@voltro/database";
|
|
7
7
|
//#region src/sqlLayer.ts
|
|
8
|
-
var
|
|
8
|
+
var N = (n) => e.layerConfig({
|
|
9
9
|
host: t.succeed(n.host),
|
|
10
10
|
port: t.succeed(n.port),
|
|
11
11
|
username: t.succeed(n.username),
|
|
12
12
|
password: t.succeed(o.make(n.password)),
|
|
13
13
|
database: t.succeed(n.database),
|
|
14
14
|
...n.maxConnections === void 0 ? {} : { maxConnections: t.succeed(n.maxConnections) }
|
|
15
|
-
}),
|
|
15
|
+
}), P = (e) => {
|
|
16
16
|
if (e.url) {
|
|
17
17
|
let t = new URL(e.url);
|
|
18
18
|
return {
|
|
@@ -32,20 +32,20 @@ var P = (n) => e.layerConfig({
|
|
|
32
32
|
database: e.database ?? "app",
|
|
33
33
|
...e.maxConnections === void 0 ? {} : { maxConnections: e.maxConnections }
|
|
34
34
|
};
|
|
35
|
-
},
|
|
35
|
+
}, F = (e) => N(P(e)), I = (e, t) => e === null ? !1 : t === null ? !0 : e.filename === t.filename ? e.position > t.position : e.filename > t.filename, L = (e) => e.msSinceProgress < e.stallThresholdMs ? "healthy" : e.primary !== null && !I(e.primary, e.reader) ? "idle-caught-up" : "reconnect", R = (e) => (e instanceof Error ? e.message : String(e ?? "")).includes("schema changed between binlog event and metadata fetch"), z = (e) => {
|
|
36
36
|
let t = e instanceof Error ? e.message : String(e ?? "");
|
|
37
37
|
return /Table\s+[^\s.]+\.(\S+)\s+schema changed between binlog event and metadata fetch/.exec(t)?.[1] ?? null;
|
|
38
|
-
},
|
|
39
|
-
let n = [...e.filter((e) => t - e <
|
|
38
|
+
}, B = "\n SELECT DISTINCT s.TABLE_NAME AS tableName\n FROM information_schema.STATISTICS s\n JOIN information_schema.COLUMNS c\n ON c.TABLE_SCHEMA = s.TABLE_SCHEMA\n AND c.TABLE_NAME = s.TABLE_NAME\n AND c.COLUMN_NAME = s.COLUMN_NAME\n WHERE s.TABLE_SCHEMA = DATABASE()\n AND s.NON_UNIQUE = 0\n AND s.SUB_PART IS NULL\n AND c.DATA_TYPE IN ('text','tinytext','mediumtext','longtext','blob','tinyblob','mediumblob','longblob')\n", V = (e) => `cdc: table '${e}' is EXCLUDED from binlog capture — its row image carries a hidden column the reader cannot account for. Cause: a UNIQUE constraint on an UNBOUNDED text column, which MariaDB backs with a HASH long-unique index; that index adds a hidden DB_ROW_HASH_n column to the row, present in the binlog and absent from information_schema.COLUMNS. Remedy: bound the column — text().maxLength(n) — so the constraint becomes an ordinary B-tree index with no hidden column. ALTER TABLE FORCE does NOT help: the rebuild recreates the index and the hidden column. Until then, cross-instance change events for this table are lost; own-node reactivity is unaffected (writes still emit inline).`, H = 5 * 6e4, U = 3, W = (e, t) => {
|
|
39
|
+
let n = [...e.filter((e) => t - e < H), t];
|
|
40
40
|
return {
|
|
41
|
-
verdict: n.length >=
|
|
41
|
+
verdict: n.length >= U ? "persistent" : "backlog",
|
|
42
42
|
hits: n
|
|
43
43
|
};
|
|
44
|
-
},
|
|
44
|
+
}, G = /* @__PURE__ */ new Set([
|
|
45
45
|
"writerows",
|
|
46
46
|
"updaterows",
|
|
47
47
|
"deleterows"
|
|
48
|
-
]),
|
|
48
|
+
]), ce = /\b(alter|rename|drop|create)\s+(table|column)?/i, K = (e) => new Promise((t) => setTimeout(t, e)), q = async (e) => {
|
|
49
49
|
let t = l({ scope: `voltro:${e.variant}:cdc` }), n;
|
|
50
50
|
try {
|
|
51
51
|
n = (await import("@vlasky/zongji")).default;
|
|
@@ -61,14 +61,14 @@ var P = (n) => e.layerConfig({
|
|
|
61
61
|
o = n.binlogName;
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
if (r === "query" && n.query &&
|
|
64
|
+
if (r === "query" && n.query && ce.test(n.query)) {
|
|
65
65
|
u && (u.tableMap = {});
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
if (n.nextPosition && o && (s = {
|
|
69
69
|
filename: o,
|
|
70
70
|
position: n.nextPosition
|
|
71
|
-
}, e.onPosition?.(s)), !
|
|
71
|
+
}, e.onPosition?.(s)), !G.has(r)) return;
|
|
72
72
|
let l = n.tableMap[n.tableId];
|
|
73
73
|
if (!l || l.parentSchema !== a) return;
|
|
74
74
|
let d = l.tableName;
|
|
@@ -147,10 +147,10 @@ var P = (n) => e.layerConfig({
|
|
|
147
147
|
u?.stop();
|
|
148
148
|
} catch {}
|
|
149
149
|
if (f++, await K(Math.min(3e4, 500 * 2 ** Math.min(f, 6))), d) return;
|
|
150
|
-
let i = s, a = C(n), c = !a &&
|
|
150
|
+
let i = s, a = C(n), c = !a && R(n), l = !1;
|
|
151
151
|
if (c) {
|
|
152
|
-
let e =
|
|
153
|
-
h.set(i, o), l = a === "persistent", l && !g.has(i) && (g.add(i), e !== null && r.add(e), t.error(
|
|
152
|
+
let e = z(n), i = e ?? "<unknown>", { verdict: a, hits: o } = W(h.get(i) ?? [], Date.now());
|
|
153
|
+
h.set(i, o), l = a === "persistent", l && !g.has(i) && (g.add(i), e !== null && r.add(e), t.error(V(i)));
|
|
154
154
|
}
|
|
155
155
|
(a || c) && (l || t.warn(c ? "cdc: un-replayable backlog event (schema moved past it) — jumping to current end + self-heal" : "cdc: binlog gap (purged/failover) — jumping to current end + self-heal"), i = e.resolveStartPosition ? await e.resolveStartPosition().catch(() => null) : null, o = i?.filename ?? null, l || e.onResync?.());
|
|
156
156
|
try {
|
|
@@ -181,7 +181,7 @@ var P = (n) => e.layerConfig({
|
|
|
181
181
|
if (d || m || Date.now() - p < v) return;
|
|
182
182
|
let n = null;
|
|
183
183
|
if (e.resolveStartPosition && (n = await e.resolveStartPosition().catch(() => null)), d || m) return;
|
|
184
|
-
let r =
|
|
184
|
+
let r = L({
|
|
185
185
|
msSinceProgress: Date.now() - p,
|
|
186
186
|
stallThresholdMs: v,
|
|
187
187
|
primary: n,
|
|
@@ -210,7 +210,7 @@ var P = (n) => e.layerConfig({
|
|
|
210
210
|
},
|
|
211
211
|
currentPosition: () => s
|
|
212
212
|
};
|
|
213
|
-
},
|
|
213
|
+
}, le = /* @__PURE__ */ new Set(["1213", "1205"]), ue = (e) => {
|
|
214
214
|
let t = e;
|
|
215
215
|
for (let e = 0; e < 5 && typeof t == "object" && t; e++) {
|
|
216
216
|
let e = t.errno;
|
|
@@ -220,8 +220,8 @@ var P = (n) => e.layerConfig({
|
|
|
220
220
|
t = t.cause;
|
|
221
221
|
}
|
|
222
222
|
}, J = (e) => {
|
|
223
|
-
let t =
|
|
224
|
-
return t !== void 0 &&
|
|
223
|
+
let t = ue(e);
|
|
224
|
+
return t !== void 0 && le.has(t);
|
|
225
225
|
}, Y = (e) => J(e) ? "retry" : "noRetry", X = (e) => {
|
|
226
226
|
if (e == null) return "null";
|
|
227
227
|
let t = typeof e;
|
|
@@ -231,19 +231,19 @@ var P = (n) => e.layerConfig({
|
|
|
231
231
|
if (Array.isArray(e)) return `[${e.map(X).join(",")}]`;
|
|
232
232
|
let n = e;
|
|
233
233
|
return `{${Object.keys(n).sort().map((e) => `${JSON.stringify(e)}:${X(n[e])}`).join(",")}}`;
|
|
234
|
-
},
|
|
234
|
+
}, Z = (e) => {
|
|
235
235
|
let t = X(e), n = 2166136261;
|
|
236
236
|
for (let e = 0; e < t.length; e++) n ^= t.charCodeAt(e), n = Math.imul(n, 16777619);
|
|
237
237
|
return (n >>> 0).toString(36);
|
|
238
|
-
},
|
|
238
|
+
}, de = (e, t) => {
|
|
239
239
|
let n = setTimeout(e, t);
|
|
240
240
|
typeof n.unref == "function" && n.unref();
|
|
241
|
-
},
|
|
241
|
+
}, fe = class {
|
|
242
242
|
variant;
|
|
243
243
|
ttlMs;
|
|
244
244
|
schedule;
|
|
245
245
|
seen = /* @__PURE__ */ new Map();
|
|
246
|
-
constructor(e, t = 6e4, n =
|
|
246
|
+
constructor(e, t = 6e4, n = de) {
|
|
247
247
|
this.variant = e, this.ttlMs = t, this.schedule = n;
|
|
248
248
|
}
|
|
249
249
|
key(e) {
|
|
@@ -257,7 +257,7 @@ var P = (n) => e.layerConfig({
|
|
|
257
257
|
} catch {
|
|
258
258
|
r = t;
|
|
259
259
|
}
|
|
260
|
-
return `${e.table} ${e.op} ${String(n)} ${
|
|
260
|
+
return `${e.table} ${e.op} ${String(n)} ${Z(r)}`;
|
|
261
261
|
}
|
|
262
262
|
admit(e) {
|
|
263
263
|
let t = this.key(e);
|
|
@@ -272,19 +272,19 @@ var P = (n) => e.layerConfig({
|
|
|
272
272
|
get pending() {
|
|
273
273
|
return this.seen.size;
|
|
274
274
|
}
|
|
275
|
-
},
|
|
275
|
+
}, pe = /* @__PURE__ */ new Set([
|
|
276
276
|
1022,
|
|
277
277
|
1062,
|
|
278
278
|
1586
|
|
279
|
-
]),
|
|
279
|
+
]), Q = async (e) => {
|
|
280
280
|
let t = e.variant ?? "mysql", n = l({ scope: `voltro:${t}` }), a = e.changeStrategy ?? "inline", o = a;
|
|
281
281
|
a === "cdc" && !e.cdcConfig && (n.warn("changeStrategy='cdc' requires cdcConfig (serverId + connection); falling back to 'inline'."), o = "inline");
|
|
282
|
-
let s = e.tracerLayer ? r.mergeAll(e.sqlLayer, e.tracerLayer) : e.sqlLayer, c = i.make(s), d = new
|
|
282
|
+
let s = e.tracerLayer ? r.mergeAll(e.sqlLayer, e.tracerLayer) : e.sqlLayer, c = i.make(s), d = new he(await c.runPromise(u), c, t, o);
|
|
283
283
|
return o === "cdc" && e.cdcConfig && await d.startCdcConsumer(e.cdcConfig), d;
|
|
284
|
-
},
|
|
284
|
+
}, me = () => {
|
|
285
285
|
let e = C();
|
|
286
|
-
return e === void 0 ? (e) => e() : (t) =>
|
|
287
|
-
},
|
|
286
|
+
return e === void 0 ? (e) => e() : (t) => ie(e, t);
|
|
287
|
+
}, he = class e {
|
|
288
288
|
sql;
|
|
289
289
|
runtime;
|
|
290
290
|
variant;
|
|
@@ -300,7 +300,7 @@ var P = (n) => e.layerConfig({
|
|
|
300
300
|
cdcStreamName = "default";
|
|
301
301
|
cdcGate;
|
|
302
302
|
constructor(e, t, n, r = "inline", i = null, a, o) {
|
|
303
|
-
this.sql = e, this.runtime = t, this.variant = n, this.changeStrategy = r, this.namespace = i, this.log = l({ scope: `voltro:${n}` }), this.emitter = a ?? new c(),
|
|
303
|
+
this.sql = e, this.runtime = t, this.variant = n, this.changeStrategy = r, this.namespace = i, this.log = l({ scope: `voltro:${n}` }), this.emitter = a ?? new c(), te(this.emitter), this.cdcGate = o ?? new fe(n);
|
|
304
304
|
}
|
|
305
305
|
withNamespace(t) {
|
|
306
306
|
return t === this.namespace ? this : new e(this.sql, this.runtime, this.variant, this.changeStrategy, t, this.emitter, this.cdcGate);
|
|
@@ -317,9 +317,9 @@ var P = (n) => e.layerConfig({
|
|
|
317
317
|
variant: this.variant
|
|
318
318
|
};
|
|
319
319
|
}
|
|
320
|
-
async executeQuery(e, t) {
|
|
321
|
-
let
|
|
322
|
-
return w(await this.runtime.runPromise(
|
|
320
|
+
async executeQuery(e, t, r) {
|
|
321
|
+
let i = S(e, this.sql, this.namespace), a = t ? n.provideService(i, d, t) : i;
|
|
322
|
+
return w(await this.runtime.runPromise(a), e.table, this.variant);
|
|
323
323
|
}
|
|
324
324
|
get supportsInsertReturning() {
|
|
325
325
|
return this.variant === "mariadb";
|
|
@@ -330,39 +330,39 @@ var P = (n) => e.layerConfig({
|
|
|
330
330
|
get supportsUpdateReturning() {
|
|
331
331
|
return !1;
|
|
332
332
|
}
|
|
333
|
-
async executeInsert(e, t, r, i) {
|
|
334
|
-
t =
|
|
335
|
-
let
|
|
333
|
+
async executeInsert(e, t, r, i, a) {
|
|
334
|
+
t = j(e, t);
|
|
335
|
+
let o = this.sql;
|
|
336
336
|
if (this.supportsInsertReturning) {
|
|
337
|
-
let
|
|
338
|
-
if (!
|
|
337
|
+
let s = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(T(t, e))} RETURNING *`, c = r ? n.provideService(s, d, r) : s, l = (await this.runtime.runPromise(c))[0];
|
|
338
|
+
if (!l) throw Error(`MysqlStore.insert: no row returned for table '${e}'`);
|
|
339
339
|
return await this.routeEvent({
|
|
340
340
|
table: e,
|
|
341
341
|
op: "insert",
|
|
342
342
|
old: null,
|
|
343
|
-
new:
|
|
344
|
-
}, i, r),
|
|
343
|
+
new: l
|
|
344
|
+
}, i, r, a), l;
|
|
345
345
|
}
|
|
346
|
-
let
|
|
347
|
-
if (
|
|
348
|
-
let t = await this.insertRecoverAutoId(e,
|
|
346
|
+
let s = T(t, e), c = t.id;
|
|
347
|
+
if (c === void 0) {
|
|
348
|
+
let t = await this.insertRecoverAutoId(e, s, r);
|
|
349
349
|
return await this.routeEvent({
|
|
350
350
|
table: e,
|
|
351
351
|
op: "insert",
|
|
352
352
|
old: null,
|
|
353
353
|
new: t
|
|
354
|
-
}, i, r), t;
|
|
354
|
+
}, i, r, a), t;
|
|
355
355
|
}
|
|
356
|
-
let
|
|
357
|
-
await this.runtime.runPromise(
|
|
358
|
-
let
|
|
359
|
-
if (!
|
|
356
|
+
let l = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(s)}`, u = r ? n.provideService(l, d, r) : l;
|
|
357
|
+
await this.runtime.runPromise(u);
|
|
358
|
+
let f = o`SELECT * FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${c}`, p = r ? n.provideService(f, d, r) : f, m = (await this.runtime.runPromise(p))[0];
|
|
359
|
+
if (!m) throw Error(`MysqlStore.insert: row not found post-insert in '${e}'`);
|
|
360
360
|
return await this.routeEvent({
|
|
361
361
|
table: e,
|
|
362
362
|
op: "insert",
|
|
363
363
|
old: null,
|
|
364
|
-
new:
|
|
365
|
-
}, i, r),
|
|
364
|
+
new: m
|
|
365
|
+
}, i, r, a), m;
|
|
366
366
|
}
|
|
367
367
|
async insertRecoverAutoId(e, t, r) {
|
|
368
368
|
let i = this.sql;
|
|
@@ -386,41 +386,41 @@ var P = (n) => e.layerConfig({
|
|
|
386
386
|
this.inflightTxns--;
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
async executeInsertMany(e, t, r, i) {
|
|
390
|
-
if (t =
|
|
391
|
-
let
|
|
389
|
+
async executeInsertMany(e, t, r, i, a) {
|
|
390
|
+
if (t = se(e, t), t.length === 0) return [];
|
|
391
|
+
let o = this.sql, s = t.map((t) => T(t, e));
|
|
392
392
|
if (this.supportsInsertReturning) {
|
|
393
|
-
let t =
|
|
394
|
-
for (let t of
|
|
393
|
+
let t = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(s)} RETURNING *`, c = r ? n.provideService(t, d, r) : t, l = await this.runtime.runPromise(c);
|
|
394
|
+
for (let t of l) await this.routeEvent({
|
|
395
395
|
table: e,
|
|
396
396
|
op: "insert",
|
|
397
397
|
old: null,
|
|
398
398
|
new: t
|
|
399
|
-
}, i, r);
|
|
400
|
-
return
|
|
399
|
+
}, i, r, a);
|
|
400
|
+
return l;
|
|
401
401
|
}
|
|
402
|
-
let
|
|
403
|
-
if (
|
|
404
|
-
let t = await this.insertManyRecoverAutoIds(e,
|
|
402
|
+
let c = t.map((e) => e.id);
|
|
403
|
+
if (c.every((e) => e === void 0)) {
|
|
404
|
+
let t = await this.insertManyRecoverAutoIds(e, s, r);
|
|
405
405
|
for (let n of t) await this.routeEvent({
|
|
406
406
|
table: e,
|
|
407
407
|
op: "insert",
|
|
408
408
|
old: null,
|
|
409
409
|
new: n
|
|
410
|
-
}, i, r);
|
|
410
|
+
}, i, r, a);
|
|
411
411
|
return t;
|
|
412
412
|
}
|
|
413
|
-
if (
|
|
414
|
-
let
|
|
415
|
-
await this.runtime.runPromise(
|
|
416
|
-
let
|
|
417
|
-
for (let t of
|
|
413
|
+
if (c.some((e) => e === void 0)) throw Error("MysqlStore.insertMany: rows mix client-supplied and missing 'id's — supply an id for every row or none (AUTO_INCREMENT recovery).");
|
|
414
|
+
let l = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(s)}`, u = r ? n.provideService(l, d, r) : l;
|
|
415
|
+
await this.runtime.runPromise(u);
|
|
416
|
+
let f = o`SELECT * FROM ${o(this.nsT(e))} WHERE ${o("id")} IN ${o.in(c)}`, p = r ? n.provideService(f, d, r) : f, m = await this.runtime.runPromise(p), h = new Map(m.map((e) => [e.id, e])), g = c.map((e) => h.get(e)).filter((e) => e !== void 0);
|
|
417
|
+
for (let t of g) await this.routeEvent({
|
|
418
418
|
table: e,
|
|
419
419
|
op: "insert",
|
|
420
420
|
old: null,
|
|
421
421
|
new: t
|
|
422
|
-
}, i, r);
|
|
423
|
-
return
|
|
422
|
+
}, i, r, a);
|
|
423
|
+
return g;
|
|
424
424
|
}
|
|
425
425
|
async insertManyRecoverAutoIds(e, t, r) {
|
|
426
426
|
let i = this.sql, a = t.length;
|
|
@@ -433,58 +433,58 @@ var P = (n) => e.layerConfig({
|
|
|
433
433
|
return yield* n.provideService(i`SELECT * FROM ${i(this.nsT(e))} WHERE ${i("id")} BETWEEN ${c} AND ${c + a - 1} ORDER BY ${i("id")} ASC`, d, r);
|
|
434
434
|
}), "insert");
|
|
435
435
|
}
|
|
436
|
-
async executePatchJson(e, t, r, i, a, o) {
|
|
437
|
-
let
|
|
438
|
-
if (
|
|
439
|
-
let
|
|
440
|
-
return
|
|
436
|
+
async executePatchJson(e, t, r, i, a, o, s) {
|
|
437
|
+
let c = this.sql, l = r.split("."), u = l[0], f = l.slice(1), p = JSON.stringify(i ?? null), m = f.length === 0 ? "$" : `$.${f.join(".")}`, h = c`UPDATE ${c(this.nsT(e))} SET ${c(u)} = JSON_SET(COALESCE(${c(u)}, '{}'), ${m}, CAST(${p} AS JSON)) WHERE ${c("id")} = ${t}`, g = a ? n.provideService(h, d, a) : h, _ = await this.runtime.runPromise(g);
|
|
438
|
+
if (_ && typeof _.affectedRows == "number" && _.affectedRows === 0) return null;
|
|
439
|
+
let v = c`SELECT * FROM ${c(this.nsT(e))} WHERE ${c("id")} = ${t}`, y = a ? n.provideService(v, d, a) : v, b = (await this.runtime.runPromise(y))[0];
|
|
440
|
+
return b ? (await this.routeEvent({
|
|
441
441
|
table: e,
|
|
442
442
|
op: "update",
|
|
443
443
|
old: null,
|
|
444
|
-
new:
|
|
445
|
-
}, o, a),
|
|
444
|
+
new: b
|
|
445
|
+
}, o, a, s), b) : null;
|
|
446
446
|
}
|
|
447
|
-
async executeUpdate(e, t, r, i, a) {
|
|
448
|
-
let
|
|
447
|
+
async executeUpdate(e, t, r, i, a, o) {
|
|
448
|
+
let s = this.sql;
|
|
449
449
|
if (this.supportsUpdateReturning) {
|
|
450
|
-
let
|
|
451
|
-
return
|
|
450
|
+
let c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(T(r, e))} WHERE ${s("id")} = ${t} RETURNING *`, l = i ? n.provideService(c, d, i) : c, u = (await this.runtime.runPromise(l))[0];
|
|
451
|
+
return u ? (await this.routeEvent({
|
|
452
452
|
table: e,
|
|
453
453
|
op: "update",
|
|
454
454
|
old: null,
|
|
455
|
-
new:
|
|
456
|
-
}, a, i),
|
|
455
|
+
new: u
|
|
456
|
+
}, a, i, o), u) : null;
|
|
457
457
|
}
|
|
458
|
-
let
|
|
459
|
-
if (
|
|
460
|
-
let
|
|
461
|
-
return
|
|
458
|
+
let c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(T(r, e))} WHERE ${s("id")} = ${t}`, l = i ? n.provideService(c, d, i) : c, u = await this.runtime.runPromise(l);
|
|
459
|
+
if (u && typeof u.affectedRows == "number" && u.affectedRows === 0) return null;
|
|
460
|
+
let f = s`SELECT * FROM ${s(this.nsT(e))} WHERE ${s("id")} = ${t}`, p = i ? n.provideService(f, d, i) : f, m = (await this.runtime.runPromise(p))[0];
|
|
461
|
+
return m ? (await this.routeEvent({
|
|
462
462
|
table: e,
|
|
463
463
|
op: "update",
|
|
464
464
|
old: null,
|
|
465
|
-
new:
|
|
466
|
-
}, a, i),
|
|
465
|
+
new: m
|
|
466
|
+
}, a, i, o), m) : null;
|
|
467
467
|
}
|
|
468
|
-
async executeDelete(e, t, r, i) {
|
|
469
|
-
let
|
|
468
|
+
async executeDelete(e, t, r, i, a) {
|
|
469
|
+
let o = this.sql;
|
|
470
470
|
if (this.supportsDeleteReturning) {
|
|
471
|
-
let
|
|
472
|
-
return
|
|
471
|
+
let s = o`DELETE FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t} RETURNING *`, c = r ? n.provideService(s, d, r) : s, l = (await this.runtime.runPromise(c))[0];
|
|
472
|
+
return l ? (await this.routeEvent({
|
|
473
473
|
table: e,
|
|
474
474
|
op: "delete",
|
|
475
|
-
old:
|
|
475
|
+
old: l,
|
|
476
476
|
new: null
|
|
477
|
-
}, i, r), !0) : !1;
|
|
477
|
+
}, i, r, a), !0) : !1;
|
|
478
478
|
}
|
|
479
|
-
let
|
|
480
|
-
if (!
|
|
481
|
-
let
|
|
482
|
-
return await this.runtime.runPromise(
|
|
479
|
+
let s = o`SELECT * FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t}`, c = r ? n.provideService(s, d, r) : s, l = (await this.runtime.runPromise(c))[0];
|
|
480
|
+
if (!l) return !1;
|
|
481
|
+
let u = o`DELETE FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t}`, f = r ? n.provideService(u, d, r) : u;
|
|
482
|
+
return await this.runtime.runPromise(f), await this.routeEvent({
|
|
483
483
|
table: e,
|
|
484
484
|
op: "delete",
|
|
485
|
-
old:
|
|
485
|
+
old: l,
|
|
486
486
|
new: null
|
|
487
|
-
}, i, r), !0;
|
|
487
|
+
}, i, r, a), !0;
|
|
488
488
|
}
|
|
489
489
|
async appendInTxn(e, t, r) {
|
|
490
490
|
let i = this.sql, a = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(T(t, e))}`;
|
|
@@ -494,11 +494,11 @@ var P = (n) => e.layerConfig({
|
|
|
494
494
|
let a = this.sql, o = Object.entries(r).map(([e, t]) => a`${a(e)} = ${t}`), s = a`SELECT MAX(${a(t)}) AS ${a("m")} FROM ${a(this.nsT(e))} WHERE ${a.and(o)}`, c = (await this.runtime.runPromise(i ? n.provideService(s, d, i) : s))[0]?.m;
|
|
495
495
|
return c == null ? null : Number(c);
|
|
496
496
|
}
|
|
497
|
-
async routeEvent(e, t, n = null) {
|
|
497
|
+
async routeEvent(e, t, n = null, r) {
|
|
498
498
|
if (e = {
|
|
499
|
-
...g(),
|
|
499
|
+
...g(r),
|
|
500
500
|
...e
|
|
501
|
-
},
|
|
501
|
+
}, ne(e.table) && await ae({
|
|
502
502
|
append: (e, t) => this.appendInTxn(e, t, n),
|
|
503
503
|
maxOf: (e, t, r) => this.maxInTxn(e, t, r, n)
|
|
504
504
|
}, {
|
|
@@ -510,7 +510,7 @@ var P = (n) => e.layerConfig({
|
|
|
510
510
|
subjectId: e.subjectId
|
|
511
511
|
}), this.changeStrategy === "cdc") {
|
|
512
512
|
let t = (e.op === "delete" ? e.old : e.new)?.id;
|
|
513
|
-
t != null &&
|
|
513
|
+
t != null && re(_(e.table, e.op, t), {
|
|
514
514
|
...e.traceId === void 0 ? {} : { traceId: e.traceId },
|
|
515
515
|
...e.subjectId === void 0 ? {} : { subjectId: e.subjectId }
|
|
516
516
|
});
|
|
@@ -521,61 +521,61 @@ var P = (n) => e.layerConfig({
|
|
|
521
521
|
}
|
|
522
522
|
this.emitChange(e);
|
|
523
523
|
}
|
|
524
|
-
async executeUpsert(e, t, n, r, i) {
|
|
524
|
+
async executeUpsert(e, t, n, r, i, a) {
|
|
525
525
|
if (this.variant === "mariadb" && typeof n.update != "function") return this.executeMariadbUpsert(e, t, {
|
|
526
526
|
conflictColumns: n.conflictColumns,
|
|
527
527
|
...n.update === void 0 ? {} : { update: n.update }
|
|
528
528
|
}, r, i);
|
|
529
|
-
let
|
|
530
|
-
if (
|
|
531
|
-
let
|
|
532
|
-
if (typeof n.update == "function")
|
|
529
|
+
let o = await this.findByConflict(e, t, n.conflictColumns, r);
|
|
530
|
+
if (o) {
|
|
531
|
+
let a;
|
|
532
|
+
if (typeof n.update == "function") a = n.update(o);
|
|
533
533
|
else if (Array.isArray(n.update)) {
|
|
534
534
|
let e = {};
|
|
535
535
|
for (let r of n.update) r in t && (e[r] = t[r]);
|
|
536
|
-
|
|
536
|
+
a = e;
|
|
537
537
|
} else {
|
|
538
538
|
let e = {};
|
|
539
539
|
for (let [r, i] of Object.entries(t)) r !== "id" && (n.conflictColumns.includes(r) || (e[r] = i));
|
|
540
|
-
|
|
540
|
+
a = e;
|
|
541
541
|
}
|
|
542
|
-
return await this.executeUpdate(e,
|
|
542
|
+
return await this.executeUpdate(e, o.id, a, r, i) ?? o;
|
|
543
543
|
}
|
|
544
|
-
return
|
|
544
|
+
return M((n) => this.executeInsert(e, t, r, i, n));
|
|
545
545
|
}
|
|
546
|
-
async executeMariadbUpsert(e, t, r, i, a) {
|
|
547
|
-
let
|
|
548
|
-
if (!
|
|
549
|
-
let
|
|
546
|
+
async executeMariadbUpsert(e, t, r, i, a, o) {
|
|
547
|
+
let s = this.sql, c = T(t, e), l = Object.keys(c).filter((e) => c[e] !== void 0), u = r.update === void 0 ? l.filter((e) => e !== "id" && !r.conflictColumns.includes(e)) : r.update, f = u.length > 0 ? s.csv(u.map((e) => s`${s(e)} = VALUES(${s(e)})`)) : s`${s(r.conflictColumns[0])} = VALUES(${s(r.conflictColumns[0])})`, p = s`INSERT INTO ${s(this.nsT(e))} ${s.insert(c)} ON DUPLICATE KEY UPDATE ${f} RETURNING *`, m = i ? n.provideService(p, d, i) : p, h = (await this.runtime.runPromise(m))[0];
|
|
548
|
+
if (!h) throw Error(`MysqlStore.upsert: no row returned for table '${e}'`);
|
|
549
|
+
let g = t.id !== void 0 && t.id === h.id ? "insert" : "update";
|
|
550
550
|
return await this.routeEvent({
|
|
551
551
|
table: e,
|
|
552
|
-
op:
|
|
552
|
+
op: g,
|
|
553
553
|
old: null,
|
|
554
|
-
new:
|
|
555
|
-
}, a, i),
|
|
554
|
+
new: h
|
|
555
|
+
}, a, i, o), h;
|
|
556
556
|
}
|
|
557
|
-
async executeInsertIgnore(e, t, r, i, a) {
|
|
558
|
-
if (t =
|
|
559
|
-
let
|
|
560
|
-
if (
|
|
557
|
+
async executeInsertIgnore(e, t, r, i, a, o) {
|
|
558
|
+
if (t = j(e, t), this.variant === "mariadb") {
|
|
559
|
+
let s = this.sql, c = s`INSERT IGNORE INTO ${s(this.nsT(e))} ${s.insert(T(t, e))} RETURNING *`, l = i ? n.provideService(c, d, i) : c, u = (await this.runtime.runPromise(l))[0];
|
|
560
|
+
if (u) return await this.routeEvent({
|
|
561
561
|
table: e,
|
|
562
562
|
op: "insert",
|
|
563
563
|
old: null,
|
|
564
|
-
new:
|
|
565
|
-
}, a, i),
|
|
566
|
-
let
|
|
567
|
-
if (
|
|
568
|
-
let
|
|
569
|
-
if (
|
|
570
|
-
let
|
|
571
|
-
throw Error(`MysqlStore.insertIgnore: the insert was skipped as a conflict, but no existing row matches conflictColumns [${r.conflictColumns.join(", ")}] on '${e}'. ` + (
|
|
564
|
+
new: u
|
|
565
|
+
}, a, i, o), u;
|
|
566
|
+
let f = await this.readWarnings(i), p = f.find((e) => !pe.has(e.code));
|
|
567
|
+
if (p !== void 0) throw Error(`MysqlStore.insertIgnore: the insert into '${e}' was REJECTED, not skipped as a conflict. INSERT IGNORE downgrades every error to a warning, and the warning was: [${p.code}] ${p.message}. Nothing was written and nothing conflicted — fix the cause above.`);
|
|
568
|
+
let m = await this.findByConflict(e, t, r.conflictColumns, i);
|
|
569
|
+
if (m) return m;
|
|
570
|
+
let h = f[0];
|
|
571
|
+
throw Error(`MysqlStore.insertIgnore: the insert was skipped as a conflict, but no existing row matches conflictColumns [${r.conflictColumns.join(", ")}] on '${e}'. ` + (h === void 0 ? "The warning could not be read on this connection, so the constraint that fired is unknown — it may be a second unique index, or the primary key under another name. " : `The constraint that actually fired: [${h.code}] ${h.message}. `) + "insertIgnore models ONE conflict target: name the columns of the constraint that actually collides, or handle the violation yourself.");
|
|
572
572
|
}
|
|
573
|
-
return await this.findByConflict(e, t, r.conflictColumns, i) ||
|
|
573
|
+
return await this.findByConflict(e, t, r.conflictColumns, i) || M((n) => this.executeInsert(e, t, i, a, n));
|
|
574
574
|
}
|
|
575
575
|
async findUndecodableCdcTables(e) {
|
|
576
576
|
if (this.variant !== "mariadb") return [];
|
|
577
577
|
try {
|
|
578
|
-
let t = (await this.runtime.runPromise(this.sql.unsafe(
|
|
578
|
+
let t = (await this.runtime.runPromise(this.sql.unsafe(B))).map((e) => String(e.tableName ?? e.TABLE_NAME ?? "")).filter((e) => e !== "");
|
|
579
579
|
return e === void 0 ? t : t.filter((t) => e.includes(t));
|
|
580
580
|
} catch (e) {
|
|
581
581
|
return this.log.debug(`cdc: could not probe for undecodable tables — ${e?.message ?? String(e)}`), [];
|
|
@@ -606,7 +606,7 @@ var P = (n) => e.layerConfig({
|
|
|
606
606
|
return this.runtime.runPromise(n);
|
|
607
607
|
}
|
|
608
608
|
async runWithEager(e, t) {
|
|
609
|
-
if (!
|
|
609
|
+
if (!D(e)) return this.executeQuery(e, t);
|
|
610
610
|
let r = this.variant === "mariadb" ? "mariadb" : "mysql", i = this.namespace === null ? y(e, this.sql, r) : null;
|
|
611
611
|
if (i !== null) try {
|
|
612
612
|
let e = t ? n.provideService(i.fragment, d, t) : i.fragment, r = await this.runtime.runPromise(e);
|
|
@@ -615,31 +615,40 @@ var P = (n) => e.layerConfig({
|
|
|
615
615
|
if (e instanceof p) throw e;
|
|
616
616
|
this.log.warn(`${this.variant} JSON-agg eager-load failed; falling back to walker`, { err: e });
|
|
617
617
|
}
|
|
618
|
-
return h(await this.executeQuery(e, t), e.eager, e.sourceTable ??
|
|
618
|
+
return h(await this.executeQuery(e, t), e.eager, e.sourceTable ?? k(e.table), (e) => this.executeQuery(e, t));
|
|
619
619
|
}
|
|
620
620
|
getInternalRunWithEager() {
|
|
621
621
|
return this.runWithEager.bind(this);
|
|
622
622
|
}
|
|
623
|
+
async localWrite(e, t) {
|
|
624
|
+
if (this.changeStrategy !== "cdc") return M(t);
|
|
625
|
+
v(e);
|
|
626
|
+
try {
|
|
627
|
+
return await M(t);
|
|
628
|
+
} finally {
|
|
629
|
+
E(e);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
623
632
|
insert(e, t) {
|
|
624
|
-
return
|
|
633
|
+
return this.localWrite(e, (n) => this.executeInsert(e, t, null, null, n));
|
|
625
634
|
}
|
|
626
635
|
insertMany(e, t) {
|
|
627
|
-
return
|
|
636
|
+
return this.localWrite(e, (n) => this.executeInsertMany(e, t, null, null, n));
|
|
628
637
|
}
|
|
629
638
|
patchJson(e, t, n, r) {
|
|
630
|
-
return
|
|
639
|
+
return this.localWrite(e, (i) => this.executePatchJson(e, t, n, r, null, null, i));
|
|
631
640
|
}
|
|
632
641
|
upsert(e, t, n) {
|
|
633
|
-
return
|
|
642
|
+
return this.localWrite(e, (r) => this.executeUpsert(e, t, n, null, null, r));
|
|
634
643
|
}
|
|
635
644
|
insertIgnore(e, t, n) {
|
|
636
|
-
return
|
|
645
|
+
return this.localWrite(e, (r) => this.executeInsertIgnore(e, t, n, null, null, r));
|
|
637
646
|
}
|
|
638
647
|
update(e, t, n) {
|
|
639
|
-
return
|
|
648
|
+
return this.localWrite(e, (r) => this.executeUpdate(e, t, n, null, null, r));
|
|
640
649
|
}
|
|
641
650
|
delete(e, t) {
|
|
642
|
-
return
|
|
651
|
+
return this.localWrite(e, (n) => this.executeDelete(e, t, null, null, n));
|
|
643
652
|
}
|
|
644
653
|
async updateMany(e, t, r) {
|
|
645
654
|
if (this.supportsUpdateReturning) {
|
|
@@ -653,7 +662,7 @@ var P = (n) => e.layerConfig({
|
|
|
653
662
|
return o.length;
|
|
654
663
|
}
|
|
655
664
|
let i = this.sql, o = b(r.where, i, this.namespace);
|
|
656
|
-
this.inflightTxns++;
|
|
665
|
+
this.changeStrategy === "cdc" && v(e), this.inflightTxns++;
|
|
657
666
|
try {
|
|
658
667
|
let r = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(d), (r) => {
|
|
659
668
|
if (a.isNone(r)) return n.fail(/* @__PURE__ */ Error("MysqlStore.updateMany: TransactionConnection missing."));
|
|
@@ -677,7 +686,7 @@ var P = (n) => e.layerConfig({
|
|
|
677
686
|
}, null, null);
|
|
678
687
|
return f.length;
|
|
679
688
|
} finally {
|
|
680
|
-
this.inflightTxns
|
|
689
|
+
this.inflightTxns--, this.changeStrategy === "cdc" && E(e);
|
|
681
690
|
}
|
|
682
691
|
}
|
|
683
692
|
async deleteMany(e, t) {
|
|
@@ -692,7 +701,7 @@ var P = (n) => e.layerConfig({
|
|
|
692
701
|
}, null, null);
|
|
693
702
|
return n.length;
|
|
694
703
|
}
|
|
695
|
-
this.inflightTxns++;
|
|
704
|
+
this.changeStrategy === "cdc" && v(e), this.inflightTxns++;
|
|
696
705
|
try {
|
|
697
706
|
let t = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(d), (t) => {
|
|
698
707
|
if (a.isNone(t)) return n.fail(/* @__PURE__ */ Error("MysqlStore.deleteMany: TransactionConnection missing."));
|
|
@@ -712,17 +721,17 @@ var P = (n) => e.layerConfig({
|
|
|
712
721
|
}, null, null);
|
|
713
722
|
return u.length;
|
|
714
723
|
} finally {
|
|
715
|
-
this.inflightTxns
|
|
724
|
+
this.inflightTxns--, this.changeStrategy === "cdc" && E(e);
|
|
716
725
|
}
|
|
717
726
|
}
|
|
718
727
|
emitChange(e) {
|
|
719
|
-
|
|
728
|
+
O(e.table) && (this.changeStrategy === "cdc" && !this.cdcGate.admit(e) || this.emitter.emit("change", e));
|
|
720
729
|
}
|
|
721
730
|
async startCdcConsumer(e) {
|
|
722
731
|
if (this.cdcHandle) return;
|
|
723
732
|
await this.assertBinlogConfig(), this.cdcReplicaId = e.replicaId;
|
|
724
733
|
let t = await this.readCdcOffset(e.replicaId) ?? await this.resolveBinlogEnd(), n = await this.findUndecodableCdcTables(e.includeTables);
|
|
725
|
-
for (let e of n) this.log.error(
|
|
734
|
+
for (let e of n) this.log.error(V(e));
|
|
726
735
|
this.cdcHandle = await q({
|
|
727
736
|
connection: e.connection,
|
|
728
737
|
serverId: e.serverId,
|
|
@@ -840,26 +849,26 @@ var P = (n) => e.layerConfig({
|
|
|
840
849
|
}
|
|
841
850
|
async transactional(e) {
|
|
842
851
|
this.inflightTxns++;
|
|
843
|
-
let t =
|
|
844
|
-
let
|
|
845
|
-
return this.sql.withTransaction(n.flatMap(n.serviceOption(d), (
|
|
846
|
-
if (a.isNone(
|
|
847
|
-
let
|
|
852
|
+
let t = C(), r = me(), i = 0, o = n.suspend(() => {
|
|
853
|
+
let o = ++i;
|
|
854
|
+
return this.sql.withTransaction(n.flatMap(n.serviceOption(d), (i) => {
|
|
855
|
+
if (a.isNone(i)) return n.fail(/* @__PURE__ */ Error("MysqlStore.transactional: TransactionConnection missing."));
|
|
856
|
+
let s = new ge(this, i.value, t);
|
|
848
857
|
return n.tryPromise({
|
|
849
|
-
try: () =>
|
|
858
|
+
try: () => r(() => e(s)).then((e) => ({
|
|
850
859
|
result: e,
|
|
851
|
-
view:
|
|
852
|
-
attempt:
|
|
860
|
+
view: s,
|
|
861
|
+
attempt: o
|
|
853
862
|
})),
|
|
854
863
|
catch: (e) => e
|
|
855
864
|
});
|
|
856
865
|
}));
|
|
857
|
-
}),
|
|
866
|
+
}), c = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(J)), l = o.pipe(n.retry(c), n.withSpan("store.transactional", { attributes: {
|
|
858
867
|
"db.system": this.variant,
|
|
859
868
|
"db.operation": "transaction"
|
|
860
869
|
} }));
|
|
861
870
|
try {
|
|
862
|
-
let e =
|
|
871
|
+
let e = oe(await this.runtime.runPromiseExit(l));
|
|
863
872
|
return e.view.commitEvents(), e.result;
|
|
864
873
|
} finally {
|
|
865
874
|
this.inflightTxns--;
|
|
@@ -874,12 +883,14 @@ var P = (n) => e.layerConfig({
|
|
|
874
883
|
return this.changeStrategy === "cdc" ? "fleet" : "local";
|
|
875
884
|
}
|
|
876
885
|
injectExternalChange(e) {
|
|
877
|
-
if (this.changeStrategy === "cdc" && !this.cdcGate.admit(e) || !
|
|
878
|
-
let t = (e.op === "delete" ? e.old : e.new)?.id
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
886
|
+
if (this.changeStrategy === "cdc" && !this.cdcGate.admit(e) || !O(e.table)) return;
|
|
887
|
+
let t = (e.op === "delete" ? e.old : e.new)?.id;
|
|
888
|
+
A(e.table, e.op, t, (t) => {
|
|
889
|
+
this.emitter.emit("change", {
|
|
890
|
+
...t,
|
|
891
|
+
...e,
|
|
892
|
+
origin: "injected"
|
|
893
|
+
});
|
|
883
894
|
});
|
|
884
895
|
}
|
|
885
896
|
run(e) {
|
|
@@ -903,31 +914,32 @@ var P = (n) => e.layerConfig({
|
|
|
903
914
|
async ping() {
|
|
904
915
|
await this.runtime.runPromise(this.sql`SELECT 1`);
|
|
905
916
|
}
|
|
906
|
-
},
|
|
917
|
+
}, ge = class {
|
|
907
918
|
parent;
|
|
908
919
|
txn;
|
|
920
|
+
attr;
|
|
909
921
|
events = [];
|
|
910
922
|
committed = !1;
|
|
911
|
-
constructor(e, t) {
|
|
912
|
-
this.parent = e, this.txn = t;
|
|
923
|
+
constructor(e, t, n = void 0) {
|
|
924
|
+
this.parent = e, this.txn = t, this.attr = n;
|
|
913
925
|
}
|
|
914
926
|
query(e) {
|
|
915
927
|
return this.parent.getInternalRunWithEager()(e, this.txn);
|
|
916
928
|
}
|
|
917
929
|
insert(e, t) {
|
|
918
|
-
return this.parent.getInternalExecuteInsert()(e, t, this.txn, this.events);
|
|
930
|
+
return this.parent.getInternalExecuteInsert()(e, t, this.txn, this.events, this.attr);
|
|
919
931
|
}
|
|
920
932
|
insertMany(e, t) {
|
|
921
|
-
return this.parent.getInternalExecuteInsertMany()(e, t, this.txn, this.events);
|
|
933
|
+
return this.parent.getInternalExecuteInsertMany()(e, t, this.txn, this.events, this.attr);
|
|
922
934
|
}
|
|
923
935
|
patchJson(e, t, n, r) {
|
|
924
|
-
return this.parent.getInternalExecutePatchJson()(e, t, n, r, this.txn, this.events);
|
|
936
|
+
return this.parent.getInternalExecutePatchJson()(e, t, n, r, this.txn, this.events, this.attr);
|
|
925
937
|
}
|
|
926
938
|
update(e, t, n) {
|
|
927
|
-
return this.parent.getInternalExecuteUpdate()(e, t, n, this.txn, this.events);
|
|
939
|
+
return this.parent.getInternalExecuteUpdate()(e, t, n, this.txn, this.events, this.attr);
|
|
928
940
|
}
|
|
929
941
|
delete(e, t) {
|
|
930
|
-
return this.parent.getInternalExecuteDelete()(e, t, this.txn, this.events);
|
|
942
|
+
return this.parent.getInternalExecuteDelete()(e, t, this.txn, this.events, this.attr);
|
|
931
943
|
}
|
|
932
944
|
async updateMany(e, t, n) {
|
|
933
945
|
let r = await this.query({
|
|
@@ -954,10 +966,10 @@ var P = (n) => e.layerConfig({
|
|
|
954
966
|
return r;
|
|
955
967
|
}
|
|
956
968
|
upsert(e, t, n) {
|
|
957
|
-
return this.parent.getInternalExecuteUpsert()(e, t, n, this.txn, this.events);
|
|
969
|
+
return this.parent.getInternalExecuteUpsert()(e, t, n, this.txn, this.events, this.attr);
|
|
958
970
|
}
|
|
959
971
|
insertIgnore(e, t, n) {
|
|
960
|
-
return this.parent.getInternalExecuteInsertIgnore()(e, t, n, this.txn, this.events);
|
|
972
|
+
return this.parent.getInternalExecuteInsertIgnore()(e, t, n, this.txn, this.events, this.attr);
|
|
961
973
|
}
|
|
962
974
|
transactional(e) {
|
|
963
975
|
return Promise.reject(/* @__PURE__ */ Error("MysqlStore.transactional: nested transactions are not supported."));
|
|
@@ -975,7 +987,7 @@ var P = (n) => e.layerConfig({
|
|
|
975
987
|
this.events.length = 0;
|
|
976
988
|
}
|
|
977
989
|
}
|
|
978
|
-
}, $ = (e) => e.__mysqlReplicationFriend ?? null,
|
|
990
|
+
}, $ = (e) => e.__mysqlReplicationFriend ?? null, _e = () => ({
|
|
979
991
|
async capturePrimaryPosition(e) {
|
|
980
992
|
let t = $(e);
|
|
981
993
|
if (t === null) throw Error("mysqlReplicationAdapter: primary is not a MysqlStore (missing __mysqlReplicationFriend).");
|
|
@@ -995,19 +1007,19 @@ var P = (n) => e.layerConfig({
|
|
|
995
1007
|
compare(e, t) {
|
|
996
1008
|
return "behind";
|
|
997
1009
|
}
|
|
998
|
-
}),
|
|
1010
|
+
}), ve = {
|
|
999
1011
|
id: "mysql",
|
|
1000
|
-
makeSqlLayer: (e) =>
|
|
1001
|
-
makeStore: (e) =>
|
|
1012
|
+
makeSqlLayer: (e) => F(e),
|
|
1013
|
+
makeStore: (e) => Q({
|
|
1002
1014
|
...e,
|
|
1003
1015
|
variant: "mysql"
|
|
1004
1016
|
}),
|
|
1005
1017
|
compileContains: (e, t, n) => n`${e} LIKE ${`%${t.replace(/[\\%_]/g, (e) => `\\${e}`)}%`} ESCAPE '\\'`,
|
|
1006
1018
|
retryFilter: Y
|
|
1007
|
-
},
|
|
1019
|
+
}, ye = {
|
|
1008
1020
|
id: "mariadb",
|
|
1009
|
-
makeSqlLayer: (e) =>
|
|
1010
|
-
makeStore: (e) =>
|
|
1021
|
+
makeSqlLayer: (e) => F(e),
|
|
1022
|
+
makeStore: (e) => Q({
|
|
1011
1023
|
...e,
|
|
1012
1024
|
variant: "mariadb"
|
|
1013
1025
|
}),
|
|
@@ -1015,4 +1027,4 @@ var P = (n) => e.layerConfig({
|
|
|
1015
1027
|
retryFilter: Y
|
|
1016
1028
|
};
|
|
1017
1029
|
//#endregion
|
|
1018
|
-
export { f as CDC_OFFSETS_TABLE, e as MysqlClient, m as _voltroCdcOffsetsTable,
|
|
1030
|
+
export { f as CDC_OFFSETS_TABLE, e as MysqlClient, m as _voltroCdcOffsetsTable, P as connectionFromConfig, N as makeMysqlSqlLayer, F as makeMysqlSqlLayerFromConfig, Q as makeMysqlStore, ye as mariadbDialect, ve as mysqlDialect, _e as mysqlReplicationAdapter, Y as mysqlRetryFilter, q as startBinlogCdc };
|