tina4-nodejs 3.13.85 → 3.13.86
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/CLAUDE.md +37 -31
- package/package.json +22 -5
- package/packages/cli/dist/bin.js +97 -91
- package/packages/core/dist/index.js +97 -91
- package/packages/core/public/js/tina4-dev-admin.min.js +90 -87
- package/packages/core/src/session.ts +2 -2
- package/packages/core/src/sessionHandlers/databaseHandler.ts +5 -6
- package/packages/frond/dist/index.js +11 -5
- package/packages/frond/src/engine.ts +27 -5
- package/packages/orm/dist/index.js +97 -91
- package/packages/orm/src/adapters/firebird.ts +11 -11
- package/packages/orm/src/adapters/mongodb.ts +13 -13
- package/packages/orm/src/adapters/mssql.ts +14 -14
- package/packages/orm/src/adapters/mysql.ts +14 -14
- package/packages/orm/src/adapters/odbc.ts +15 -15
- package/packages/orm/src/adapters/postgres.ts +17 -17
- package/packages/orm/src/adapters/sqlite.ts +14 -14
- package/packages/orm/src/autoCrud.ts +1 -1
- package/packages/orm/src/cachedDatabase.ts +1 -1
- package/packages/orm/src/database.ts +2 -2
- package/packages/orm/src/types.ts +4 -4
|
@@ -3703,11 +3703,14 @@ function resolveVar(expr, context) {
|
|
|
3703
3703
|
return value;
|
|
3704
3704
|
}
|
|
3705
3705
|
function findOutsideQuotes(expr, needle) {
|
|
3706
|
+
if (!expr.includes(needle)) return -1;
|
|
3706
3707
|
let inQuote = null;
|
|
3707
3708
|
let depth = 0;
|
|
3708
3709
|
let bracketDepth = 0;
|
|
3709
3710
|
let i = 0;
|
|
3710
|
-
|
|
3711
|
+
const needleLen = needle.length;
|
|
3712
|
+
const lastStart = expr.length - needleLen;
|
|
3713
|
+
while (i <= lastStart) {
|
|
3711
3714
|
const ch = expr[i];
|
|
3712
3715
|
if ((ch === '"' || ch === "'") && depth === 0 && bracketDepth === 0) {
|
|
3713
3716
|
if (inQuote === null) {
|
|
@@ -3726,7 +3729,7 @@ function findOutsideQuotes(expr, needle) {
|
|
|
3726
3729
|
else if (ch === ")") depth--;
|
|
3727
3730
|
else if (ch === "[") bracketDepth++;
|
|
3728
3731
|
else if (ch === "]") bracketDepth--;
|
|
3729
|
-
if (depth === 0 && bracketDepth === 0 && expr.
|
|
3732
|
+
if (depth === 0 && bracketDepth === 0 && expr.startsWith(needle, i)) {
|
|
3730
3733
|
return i;
|
|
3731
3734
|
}
|
|
3732
3735
|
i++;
|
|
@@ -3734,13 +3737,16 @@ function findOutsideQuotes(expr, needle) {
|
|
|
3734
3737
|
return -1;
|
|
3735
3738
|
}
|
|
3736
3739
|
function splitOutsideQuotes(expr, sep5) {
|
|
3740
|
+
if (!expr.includes(sep5)) return [expr];
|
|
3737
3741
|
const parts = [];
|
|
3738
3742
|
let currentStart = 0;
|
|
3739
3743
|
let inQuote = null;
|
|
3740
3744
|
let depth = 0;
|
|
3741
3745
|
let bracketDepth = 0;
|
|
3742
3746
|
let i = 0;
|
|
3743
|
-
|
|
3747
|
+
const sepLen = sep5.length;
|
|
3748
|
+
const lastStart = expr.length - sepLen;
|
|
3749
|
+
while (i <= lastStart) {
|
|
3744
3750
|
const ch = expr[i];
|
|
3745
3751
|
if ((ch === '"' || ch === "'") && depth === 0 && bracketDepth === 0) {
|
|
3746
3752
|
if (inQuote === null) {
|
|
@@ -3759,9 +3765,9 @@ function splitOutsideQuotes(expr, sep5) {
|
|
|
3759
3765
|
else if (ch === ")") depth--;
|
|
3760
3766
|
else if (ch === "[") bracketDepth++;
|
|
3761
3767
|
else if (ch === "]") bracketDepth--;
|
|
3762
|
-
if (depth === 0 && bracketDepth === 0 && expr.
|
|
3768
|
+
if (depth === 0 && bracketDepth === 0 && expr.startsWith(sep5, i)) {
|
|
3763
3769
|
parts.push(expr.slice(currentStart, i));
|
|
3764
|
-
i +=
|
|
3770
|
+
i += sepLen;
|
|
3765
3771
|
currentStart = i;
|
|
3766
3772
|
continue;
|
|
3767
3773
|
}
|
|
@@ -29454,7 +29460,7 @@ var init_sqlite = __esm({
|
|
|
29454
29460
|
this.db.exec("ROLLBACK");
|
|
29455
29461
|
throw e;
|
|
29456
29462
|
}
|
|
29457
|
-
return { totalAffected,
|
|
29463
|
+
return { totalAffected, lastId };
|
|
29458
29464
|
}
|
|
29459
29465
|
query(sql, params) {
|
|
29460
29466
|
const stmt = this.db.prepare(sql);
|
|
@@ -29480,13 +29486,13 @@ var init_sqlite = __esm({
|
|
|
29480
29486
|
}
|
|
29481
29487
|
insert(table2, data) {
|
|
29482
29488
|
if (Array.isArray(data)) {
|
|
29483
|
-
if (data.length === 0) return { success: true,
|
|
29489
|
+
if (data.length === 0) return { success: true, affectedRows: 0 };
|
|
29484
29490
|
const keys2 = Object.keys(data[0]);
|
|
29485
29491
|
const placeholders2 = keys2.map(() => "?").join(", ");
|
|
29486
29492
|
const sql2 = `INSERT INTO "${table2}" ("${keys2.join('", "')}") VALUES (${placeholders2})`;
|
|
29487
29493
|
const paramsList = data.map((row) => keys2.map((k) => row[k]));
|
|
29488
29494
|
const result = this.executeMany(sql2, paramsList);
|
|
29489
|
-
return { success: true,
|
|
29495
|
+
return { success: true, affectedRows: result.totalAffected, lastId: result.lastId };
|
|
29490
29496
|
}
|
|
29491
29497
|
const keys = Object.keys(data);
|
|
29492
29498
|
const placeholders = keys.map(() => "?").join(", ");
|
|
@@ -29495,9 +29501,9 @@ var init_sqlite = __esm({
|
|
|
29495
29501
|
try {
|
|
29496
29502
|
const result = this.db.prepare(sql).run(...toSqlParams(values));
|
|
29497
29503
|
this._lastInsertId = result.lastInsertRowid;
|
|
29498
|
-
return { success: true,
|
|
29504
|
+
return { success: true, affectedRows: Number(result.changes), lastId: result.lastInsertRowid };
|
|
29499
29505
|
} catch (e) {
|
|
29500
|
-
return { success: false,
|
|
29506
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
29501
29507
|
}
|
|
29502
29508
|
}
|
|
29503
29509
|
update(table2, data, filter, params) {
|
|
@@ -29507,9 +29513,9 @@ var init_sqlite = __esm({
|
|
|
29507
29513
|
const values = [...Object.values(data), ...Object.values(filter)];
|
|
29508
29514
|
try {
|
|
29509
29515
|
const result = this.db.prepare(sql).run(...toSqlParams(values));
|
|
29510
|
-
return { success: true,
|
|
29516
|
+
return { success: true, affectedRows: Number(result.changes) };
|
|
29511
29517
|
} catch (e) {
|
|
29512
|
-
return { success: false,
|
|
29518
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
29513
29519
|
}
|
|
29514
29520
|
}
|
|
29515
29521
|
delete(table2, filter, params) {
|
|
@@ -29517,17 +29523,17 @@ var init_sqlite = __esm({
|
|
|
29517
29523
|
let totalAffected = 0;
|
|
29518
29524
|
for (const row of filter) {
|
|
29519
29525
|
const result = this.delete(table2, row);
|
|
29520
|
-
totalAffected += result.
|
|
29526
|
+
totalAffected += result.affectedRows;
|
|
29521
29527
|
}
|
|
29522
|
-
return { success: true,
|
|
29528
|
+
return { success: true, affectedRows: totalAffected };
|
|
29523
29529
|
}
|
|
29524
29530
|
if (typeof filter === "string") {
|
|
29525
29531
|
const sql2 = filter ? `DELETE FROM "${table2}" WHERE ${filter}` : `DELETE FROM "${table2}"`;
|
|
29526
29532
|
try {
|
|
29527
29533
|
const result = this.db.prepare(sql2).run(...toSqlParams(params ?? []));
|
|
29528
|
-
return { success: true,
|
|
29534
|
+
return { success: true, affectedRows: Number(result.changes) };
|
|
29529
29535
|
} catch (e) {
|
|
29530
|
-
return { success: false,
|
|
29536
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
29531
29537
|
}
|
|
29532
29538
|
}
|
|
29533
29539
|
const whereClauses = Object.keys(filter).map((k) => `"${k}" = ?`).join(" AND ");
|
|
@@ -29535,9 +29541,9 @@ var init_sqlite = __esm({
|
|
|
29535
29541
|
const values = Object.values(filter);
|
|
29536
29542
|
try {
|
|
29537
29543
|
const result = this.db.prepare(sql).run(...toSqlParams(values));
|
|
29538
|
-
return { success: true,
|
|
29544
|
+
return { success: true, affectedRows: Number(result.changes) };
|
|
29539
29545
|
} catch (e) {
|
|
29540
|
-
return { success: false,
|
|
29546
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
29541
29547
|
}
|
|
29542
29548
|
}
|
|
29543
29549
|
_inTransaction = false;
|
|
@@ -29778,7 +29784,7 @@ var init_postgres = __esm({
|
|
|
29778
29784
|
}
|
|
29779
29785
|
/**
|
|
29780
29786
|
* Normalise an `id` column value (typed `unknown` because pg row values are
|
|
29781
|
-
* `unknown`) into the shape `_lastInsertId` / `DatabaseResult.
|
|
29787
|
+
* `unknown`) into the shape `_lastInsertId` / `DatabaseResult.lastId`
|
|
29782
29788
|
* expect. At runtime PG returns numeric PKs as number/bigint (the int8/numeric
|
|
29783
29789
|
* type parsers above coerce them to Number); a numeric string is coerced to a
|
|
29784
29790
|
* number so the SERIAL path always returns the integer id.
|
|
@@ -29813,8 +29819,8 @@ var init_postgres = __esm({
|
|
|
29813
29819
|
for (const params of paramsList) {
|
|
29814
29820
|
const result = await this.executeAsync(sql, params);
|
|
29815
29821
|
totalAffected++;
|
|
29816
|
-
if (result && typeof result === "object" && "
|
|
29817
|
-
lastId = result.
|
|
29822
|
+
if (result && typeof result === "object" && "lastId" in result) {
|
|
29823
|
+
lastId = result.lastId;
|
|
29818
29824
|
}
|
|
29819
29825
|
}
|
|
29820
29826
|
if (owns) await this.commitAsync();
|
|
@@ -29827,7 +29833,7 @@ var init_postgres = __esm({
|
|
|
29827
29833
|
}
|
|
29828
29834
|
throw e;
|
|
29829
29835
|
}
|
|
29830
|
-
return { totalAffected,
|
|
29836
|
+
return { totalAffected, lastId };
|
|
29831
29837
|
}
|
|
29832
29838
|
/** Async execute for real usage. */
|
|
29833
29839
|
async executeAsync(sql, params) {
|
|
@@ -29875,17 +29881,17 @@ var init_postgres = __esm({
|
|
|
29875
29881
|
async insertAsync(table2, data) {
|
|
29876
29882
|
this.ensureConnected();
|
|
29877
29883
|
if (Array.isArray(data)) {
|
|
29878
|
-
if (data.length === 0) return { success: true,
|
|
29884
|
+
if (data.length === 0) return { success: true, affectedRows: 0 };
|
|
29879
29885
|
const keys2 = Object.keys(data[0]);
|
|
29880
29886
|
const placeholders2 = keys2.map(() => "?").join(", ");
|
|
29881
29887
|
const sql2 = `INSERT INTO "${table2}" ("${keys2.join('", "')}") VALUES (${placeholders2})`;
|
|
29882
29888
|
const paramsList = data.map((row) => keys2.map((k) => row[k]));
|
|
29883
29889
|
try {
|
|
29884
29890
|
const result = await this.executeManyAsync(sql2, paramsList);
|
|
29885
|
-
if (result.
|
|
29886
|
-
return { success: true,
|
|
29891
|
+
if (result.lastId !== void 0) this._lastInsertId = result.lastId;
|
|
29892
|
+
return { success: true, affectedRows: result.totalAffected, lastId: result.lastId };
|
|
29887
29893
|
} catch (e) {
|
|
29888
|
-
return { success: false,
|
|
29894
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
29889
29895
|
}
|
|
29890
29896
|
}
|
|
29891
29897
|
const keys = Object.keys(data);
|
|
@@ -29899,11 +29905,11 @@ var init_postgres = __esm({
|
|
|
29899
29905
|
if (id !== null) this._lastInsertId = id;
|
|
29900
29906
|
return {
|
|
29901
29907
|
success: true,
|
|
29902
|
-
|
|
29903
|
-
|
|
29908
|
+
affectedRows: result.rowCount ?? 1,
|
|
29909
|
+
lastId: id ?? void 0
|
|
29904
29910
|
};
|
|
29905
29911
|
} catch (e) {
|
|
29906
|
-
return { success: false,
|
|
29912
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
29907
29913
|
}
|
|
29908
29914
|
}
|
|
29909
29915
|
update(table2, data, filter, params) {
|
|
@@ -29920,9 +29926,9 @@ var init_postgres = __esm({
|
|
|
29920
29926
|
const values = [...Object.values(data), ...Object.values(filter)];
|
|
29921
29927
|
try {
|
|
29922
29928
|
const result = await this.client.query(sql, values);
|
|
29923
|
-
return { success: true,
|
|
29929
|
+
return { success: true, affectedRows: result.rowCount ?? 0 };
|
|
29924
29930
|
} catch (e) {
|
|
29925
|
-
return { success: false,
|
|
29931
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
29926
29932
|
}
|
|
29927
29933
|
}
|
|
29928
29934
|
delete(table2, filter, params) {
|
|
@@ -29937,9 +29943,9 @@ var init_postgres = __esm({
|
|
|
29937
29943
|
const values = Object.values(filter);
|
|
29938
29944
|
try {
|
|
29939
29945
|
const result = await this.client.query(sql, values);
|
|
29940
|
-
return { success: true,
|
|
29946
|
+
return { success: true, affectedRows: result.rowCount ?? 0 };
|
|
29941
29947
|
} catch (e) {
|
|
29942
|
-
return { success: false,
|
|
29948
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
29943
29949
|
}
|
|
29944
29950
|
}
|
|
29945
29951
|
startTransaction() {
|
|
@@ -30173,7 +30179,7 @@ var init_mysql = __esm({
|
|
|
30173
30179
|
}
|
|
30174
30180
|
throw e;
|
|
30175
30181
|
}
|
|
30176
|
-
return { totalAffected,
|
|
30182
|
+
return { totalAffected, lastId };
|
|
30177
30183
|
}
|
|
30178
30184
|
async executeAsync(sql, params) {
|
|
30179
30185
|
this.ensureConnected();
|
|
@@ -30219,17 +30225,17 @@ var init_mysql = __esm({
|
|
|
30219
30225
|
async insertAsync(table2, data) {
|
|
30220
30226
|
this.ensureConnected();
|
|
30221
30227
|
if (Array.isArray(data)) {
|
|
30222
|
-
if (data.length === 0) return { success: true,
|
|
30228
|
+
if (data.length === 0) return { success: true, affectedRows: 0 };
|
|
30223
30229
|
const keys2 = Object.keys(data[0]);
|
|
30224
30230
|
const placeholders2 = keys2.map(() => "?").join(", ");
|
|
30225
30231
|
const sql2 = `INSERT INTO \`${table2}\` (\`${keys2.join("`, `")}\`) VALUES (${placeholders2})`;
|
|
30226
30232
|
const paramsList = data.map((row) => keys2.map((k) => row[k]));
|
|
30227
30233
|
try {
|
|
30228
30234
|
const result = await this.executeManyAsync(sql2, paramsList);
|
|
30229
|
-
if (result.
|
|
30230
|
-
return { success: true,
|
|
30235
|
+
if (result.lastId !== void 0) this._lastInsertId = result.lastId;
|
|
30236
|
+
return { success: true, affectedRows: result.totalAffected, lastId: result.lastId };
|
|
30231
30237
|
} catch (e) {
|
|
30232
|
-
return { success: false,
|
|
30238
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
30233
30239
|
}
|
|
30234
30240
|
}
|
|
30235
30241
|
const keys = Object.keys(data);
|
|
@@ -30241,11 +30247,11 @@ var init_mysql = __esm({
|
|
|
30241
30247
|
this._lastInsertId = result.insertId ?? null;
|
|
30242
30248
|
return {
|
|
30243
30249
|
success: true,
|
|
30244
|
-
|
|
30245
|
-
|
|
30250
|
+
affectedRows: result.affectedRows ?? 1,
|
|
30251
|
+
lastId: result.insertId
|
|
30246
30252
|
};
|
|
30247
30253
|
} catch (e) {
|
|
30248
|
-
return { success: false,
|
|
30254
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
30249
30255
|
}
|
|
30250
30256
|
}
|
|
30251
30257
|
update(table2, data, filter, params) {
|
|
@@ -30259,9 +30265,9 @@ var init_mysql = __esm({
|
|
|
30259
30265
|
const values = [...Object.values(data), ...Object.values(filter)];
|
|
30260
30266
|
try {
|
|
30261
30267
|
const result = await this.queryPromise(sql, values);
|
|
30262
|
-
return { success: true,
|
|
30268
|
+
return { success: true, affectedRows: result.affectedRows ?? 0 };
|
|
30263
30269
|
} catch (e) {
|
|
30264
|
-
return { success: false,
|
|
30270
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
30265
30271
|
}
|
|
30266
30272
|
}
|
|
30267
30273
|
delete(table2, filter, params) {
|
|
@@ -30274,9 +30280,9 @@ var init_mysql = __esm({
|
|
|
30274
30280
|
const values = Object.values(filter);
|
|
30275
30281
|
try {
|
|
30276
30282
|
const result = await this.queryPromise(sql, values);
|
|
30277
|
-
return { success: true,
|
|
30283
|
+
return { success: true, affectedRows: result.affectedRows ?? 0 };
|
|
30278
30284
|
} catch (e) {
|
|
30279
|
-
return { success: false,
|
|
30285
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
30280
30286
|
}
|
|
30281
30287
|
}
|
|
30282
30288
|
startTransaction() {
|
|
@@ -30617,17 +30623,17 @@ var init_mssql = __esm({
|
|
|
30617
30623
|
async insertAsync(table2, data) {
|
|
30618
30624
|
this.ensureConnected();
|
|
30619
30625
|
if (Array.isArray(data)) {
|
|
30620
|
-
if (data.length === 0) return { success: true,
|
|
30626
|
+
if (data.length === 0) return { success: true, affectedRows: 0 };
|
|
30621
30627
|
const keys2 = Object.keys(data[0]);
|
|
30622
30628
|
const placeholders2 = keys2.map(() => "?").join(", ");
|
|
30623
30629
|
const sql2 = `INSERT INTO [${table2}] ([${keys2.join("], [")}]) VALUES (${placeholders2})`;
|
|
30624
30630
|
const paramsList = data.map((row) => keys2.map((k) => row[k]));
|
|
30625
30631
|
try {
|
|
30626
30632
|
const result = await this.executeManyAsync(sql2, paramsList);
|
|
30627
|
-
if (result.
|
|
30628
|
-
return { success: true,
|
|
30633
|
+
if (result.lastId !== void 0) this._lastInsertId = result.lastId;
|
|
30634
|
+
return { success: true, affectedRows: result.totalAffected, lastId: result.lastId };
|
|
30629
30635
|
} catch (e) {
|
|
30630
|
-
return { success: false,
|
|
30636
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
30631
30637
|
}
|
|
30632
30638
|
}
|
|
30633
30639
|
const keys = Object.keys(data);
|
|
@@ -30643,12 +30649,12 @@ var init_mssql = __esm({
|
|
|
30643
30649
|
// A single-object insert affects exactly one row. Do NOT use
|
|
30644
30650
|
// result.rowCount here: the statement is "INSERT ...; SELECT
|
|
30645
30651
|
// SCOPE_IDENTITY()", and tedious sums the row counts of BOTH statements
|
|
30646
|
-
// (1 for the INSERT + 1 for the SELECT), which reported
|
|
30647
|
-
|
|
30648
|
-
|
|
30652
|
+
// (1 for the INSERT + 1 for the SELECT), which reported affectedRows=2.
|
|
30653
|
+
affectedRows: 1,
|
|
30654
|
+
lastId: id ?? void 0
|
|
30649
30655
|
};
|
|
30650
30656
|
} catch (e) {
|
|
30651
|
-
return { success: false,
|
|
30657
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
30652
30658
|
}
|
|
30653
30659
|
}
|
|
30654
30660
|
update(table2, data, filter, params) {
|
|
@@ -30665,9 +30671,9 @@ var init_mssql = __esm({
|
|
|
30665
30671
|
const values = [...Object.values(data), ...Object.values(filter)];
|
|
30666
30672
|
try {
|
|
30667
30673
|
const result = await this.execSqlPromise(sql, values);
|
|
30668
|
-
return { success: true,
|
|
30674
|
+
return { success: true, affectedRows: result.rowCount };
|
|
30669
30675
|
} catch (e) {
|
|
30670
|
-
return { success: false,
|
|
30676
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
30671
30677
|
}
|
|
30672
30678
|
}
|
|
30673
30679
|
delete(table2, filter, params) {
|
|
@@ -30682,9 +30688,9 @@ var init_mssql = __esm({
|
|
|
30682
30688
|
const values = Object.values(filter);
|
|
30683
30689
|
try {
|
|
30684
30690
|
const result = await this.execSqlPromise(sql, values);
|
|
30685
|
-
return { success: true,
|
|
30691
|
+
return { success: true, affectedRows: result.rowCount };
|
|
30686
30692
|
} catch (e) {
|
|
30687
|
-
return { success: false,
|
|
30693
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
30688
30694
|
}
|
|
30689
30695
|
}
|
|
30690
30696
|
startTransaction() {
|
|
@@ -31053,16 +31059,16 @@ var init_firebird = __esm({
|
|
|
31053
31059
|
async insertAsync(table2, data) {
|
|
31054
31060
|
this.ensureConnected();
|
|
31055
31061
|
if (Array.isArray(data)) {
|
|
31056
|
-
if (data.length === 0) return { success: true,
|
|
31062
|
+
if (data.length === 0) return { success: true, affectedRows: 0 };
|
|
31057
31063
|
const keys2 = Object.keys(data[0]);
|
|
31058
31064
|
const placeholders2 = keys2.map(() => "?").join(", ");
|
|
31059
31065
|
const sql2 = `INSERT INTO "${table2}" ("${keys2.join('", "')}") VALUES (${placeholders2})`;
|
|
31060
31066
|
const paramsList = data.map((row) => keys2.map((k) => row[k]));
|
|
31061
31067
|
try {
|
|
31062
31068
|
const result = await this.executeManyAsync(sql2, paramsList);
|
|
31063
|
-
return { success: true,
|
|
31069
|
+
return { success: true, affectedRows: result.totalAffected, lastId: result.lastId };
|
|
31064
31070
|
} catch (e) {
|
|
31065
|
-
return { success: false,
|
|
31071
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
31066
31072
|
}
|
|
31067
31073
|
}
|
|
31068
31074
|
const keys = Object.keys(data);
|
|
@@ -31073,10 +31079,10 @@ var init_firebird = __esm({
|
|
|
31073
31079
|
await this.executePromise(sql, values);
|
|
31074
31080
|
return {
|
|
31075
31081
|
success: true,
|
|
31076
|
-
|
|
31082
|
+
affectedRows: 1
|
|
31077
31083
|
};
|
|
31078
31084
|
} catch (e) {
|
|
31079
|
-
return { success: false,
|
|
31085
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
31080
31086
|
}
|
|
31081
31087
|
}
|
|
31082
31088
|
update(table2, data, filter, params) {
|
|
@@ -31090,9 +31096,9 @@ var init_firebird = __esm({
|
|
|
31090
31096
|
const values = [...Object.values(data), ...Object.values(filter)];
|
|
31091
31097
|
try {
|
|
31092
31098
|
await this.executePromise(sql, values);
|
|
31093
|
-
return { success: true,
|
|
31099
|
+
return { success: true, affectedRows: 1 };
|
|
31094
31100
|
} catch (e) {
|
|
31095
|
-
return { success: false,
|
|
31101
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
31096
31102
|
}
|
|
31097
31103
|
}
|
|
31098
31104
|
delete(table2, filter, params) {
|
|
@@ -31105,9 +31111,9 @@ var init_firebird = __esm({
|
|
|
31105
31111
|
const values = Object.values(filter);
|
|
31106
31112
|
try {
|
|
31107
31113
|
await this.executePromise(sql, values);
|
|
31108
|
-
return { success: true,
|
|
31114
|
+
return { success: true, affectedRows: 1 };
|
|
31109
31115
|
} catch (e) {
|
|
31110
|
-
return { success: false,
|
|
31116
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
31111
31117
|
}
|
|
31112
31118
|
}
|
|
31113
31119
|
startTransaction() {
|
|
@@ -31603,14 +31609,14 @@ var init_mongodb = __esm({
|
|
|
31603
31609
|
const col = this.db.collection(table2);
|
|
31604
31610
|
try {
|
|
31605
31611
|
if (Array.isArray(data)) {
|
|
31606
|
-
if (data.length === 0) return { success: true,
|
|
31612
|
+
if (data.length === 0) return { success: true, affectedRows: 0 };
|
|
31607
31613
|
const result2 = await col.insertMany(data, { session: this.session });
|
|
31608
|
-
return { success: true,
|
|
31614
|
+
return { success: true, affectedRows: result2.insertedCount };
|
|
31609
31615
|
}
|
|
31610
31616
|
const result = await col.insertOne(data, { session: this.session });
|
|
31611
|
-
return { success: true,
|
|
31617
|
+
return { success: true, affectedRows: 1, lastId: void 0 };
|
|
31612
31618
|
} catch (e) {
|
|
31613
|
-
return { success: false,
|
|
31619
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
31614
31620
|
}
|
|
31615
31621
|
}
|
|
31616
31622
|
update(table2, data, filter) {
|
|
@@ -31621,9 +31627,9 @@ var init_mongodb = __esm({
|
|
|
31621
31627
|
const col = this.db.collection(table2);
|
|
31622
31628
|
try {
|
|
31623
31629
|
const result = await col.updateMany(filter, { $set: data }, { session: this.session });
|
|
31624
|
-
return { success: true,
|
|
31630
|
+
return { success: true, affectedRows: result.modifiedCount };
|
|
31625
31631
|
} catch (e) {
|
|
31626
|
-
return { success: false,
|
|
31632
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
31627
31633
|
}
|
|
31628
31634
|
}
|
|
31629
31635
|
delete(table2, filter) {
|
|
@@ -31639,21 +31645,21 @@ var init_mongodb = __esm({
|
|
|
31639
31645
|
const r = await col.deleteMany(f, { session: this.session });
|
|
31640
31646
|
total += r.deletedCount;
|
|
31641
31647
|
}
|
|
31642
|
-
return { success: true,
|
|
31648
|
+
return { success: true, affectedRows: total };
|
|
31643
31649
|
}
|
|
31644
31650
|
if (typeof filter === "string") {
|
|
31645
31651
|
if (!filter.trim()) {
|
|
31646
31652
|
const r2 = await col.deleteMany({}, { session: this.session });
|
|
31647
|
-
return { success: true,
|
|
31653
|
+
return { success: true, affectedRows: r2.deletedCount };
|
|
31648
31654
|
}
|
|
31649
31655
|
const { filter: parsedFilter } = parseWhereClause(filter, []);
|
|
31650
31656
|
const r = await col.deleteMany(parsedFilter, { session: this.session });
|
|
31651
|
-
return { success: true,
|
|
31657
|
+
return { success: true, affectedRows: r.deletedCount };
|
|
31652
31658
|
}
|
|
31653
31659
|
const result = await col.deleteMany(filter, { session: this.session });
|
|
31654
|
-
return { success: true,
|
|
31660
|
+
return { success: true, affectedRows: result.deletedCount };
|
|
31655
31661
|
} catch (e) {
|
|
31656
|
-
return { success: false,
|
|
31662
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
31657
31663
|
}
|
|
31658
31664
|
}
|
|
31659
31665
|
startTransaction() {
|
|
@@ -31913,8 +31919,8 @@ var init_odbc = __esm({
|
|
|
31913
31919
|
async executeAsync(sql, params) {
|
|
31914
31920
|
this.ensureConnected();
|
|
31915
31921
|
const result = await this.connection.query(sql, params ?? []);
|
|
31916
|
-
if (result && typeof result === "object" && "
|
|
31917
|
-
this._lastInsertId = result.
|
|
31922
|
+
if (result && typeof result === "object" && "lastId" in result) {
|
|
31923
|
+
this._lastInsertId = result.lastId;
|
|
31918
31924
|
}
|
|
31919
31925
|
return result;
|
|
31920
31926
|
}
|
|
@@ -31935,7 +31941,7 @@ var init_odbc = __esm({
|
|
|
31935
31941
|
throw e;
|
|
31936
31942
|
}
|
|
31937
31943
|
if (lastId !== void 0) this._lastInsertId = lastId;
|
|
31938
|
-
return { totalAffected,
|
|
31944
|
+
return { totalAffected, lastId };
|
|
31939
31945
|
}
|
|
31940
31946
|
/** Run a SELECT and return all matching rows. */
|
|
31941
31947
|
async queryAsync(sql, params) {
|
|
@@ -31971,9 +31977,9 @@ var init_odbc = __esm({
|
|
|
31971
31977
|
const values = Object.values(data);
|
|
31972
31978
|
try {
|
|
31973
31979
|
await this.connection.query(sql, values);
|
|
31974
|
-
return { success: true,
|
|
31980
|
+
return { success: true, affectedRows: 1, lastId: this._lastInsertId ?? void 0 };
|
|
31975
31981
|
} catch (e) {
|
|
31976
|
-
return { success: false,
|
|
31982
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
31977
31983
|
}
|
|
31978
31984
|
}
|
|
31979
31985
|
/** Update rows in a table matching filter. */
|
|
@@ -31985,9 +31991,9 @@ var init_odbc = __esm({
|
|
|
31985
31991
|
const values = [...Object.values(data), ...Object.values(filter)];
|
|
31986
31992
|
try {
|
|
31987
31993
|
await this.connection.query(sql, values);
|
|
31988
|
-
return { success: true,
|
|
31994
|
+
return { success: true, affectedRows: 1 };
|
|
31989
31995
|
} catch (e) {
|
|
31990
|
-
return { success: false,
|
|
31996
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
31991
31997
|
}
|
|
31992
31998
|
}
|
|
31993
31999
|
/** Delete rows from a table. */
|
|
@@ -31997,17 +32003,17 @@ var init_odbc = __esm({
|
|
|
31997
32003
|
let totalAffected = 0;
|
|
31998
32004
|
for (const row of filter) {
|
|
31999
32005
|
const result = await this.deleteAsync(table2, row);
|
|
32000
|
-
totalAffected += result.
|
|
32006
|
+
totalAffected += result.affectedRows;
|
|
32001
32007
|
}
|
|
32002
|
-
return { success: true,
|
|
32008
|
+
return { success: true, affectedRows: totalAffected };
|
|
32003
32009
|
}
|
|
32004
32010
|
if (typeof filter === "string") {
|
|
32005
32011
|
const sql2 = filter ? `DELETE FROM "${table2}" WHERE ${filter}` : `DELETE FROM "${table2}"`;
|
|
32006
32012
|
try {
|
|
32007
32013
|
await this.connection.query(sql2, []);
|
|
32008
|
-
return { success: true,
|
|
32014
|
+
return { success: true, affectedRows: 1 };
|
|
32009
32015
|
} catch (e) {
|
|
32010
|
-
return { success: false,
|
|
32016
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
32011
32017
|
}
|
|
32012
32018
|
}
|
|
32013
32019
|
const whereClauses = Object.keys(filter).map((k) => `"${k}" = ?`).join(" AND ");
|
|
@@ -32015,9 +32021,9 @@ var init_odbc = __esm({
|
|
|
32015
32021
|
const values = Object.values(filter);
|
|
32016
32022
|
try {
|
|
32017
32023
|
await this.connection.query(sql, values);
|
|
32018
|
-
return { success: true,
|
|
32024
|
+
return { success: true, affectedRows: 1 };
|
|
32019
32025
|
} catch (e) {
|
|
32020
|
-
return { success: false,
|
|
32026
|
+
return { success: false, affectedRows: 0, error: e.message };
|
|
32021
32027
|
}
|
|
32022
32028
|
}
|
|
32023
32029
|
/** Begin a transaction. */
|
|
@@ -32197,7 +32203,7 @@ function extractLastInsertId(result) {
|
|
|
32197
32203
|
const r = result;
|
|
32198
32204
|
if (r.lastInsertRowid !== void 0 && r.lastInsertRowid !== null) return r.lastInsertRowid;
|
|
32199
32205
|
if (r.rows?.[0]?.id !== void 0 && r.rows[0].id !== null) return r.rows[0].id;
|
|
32200
|
-
if (r.
|
|
32206
|
+
if (r.lastId !== void 0 && r.lastId !== null) return r.lastId;
|
|
32201
32207
|
}
|
|
32202
32208
|
return null;
|
|
32203
32209
|
}
|
|
@@ -260,11 +260,11 @@ export class FirebirdAdapter implements DatabaseAdapter {
|
|
|
260
260
|
throw new Error("Use executeAsync() for Firebird — async adapter requires async methods.");
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
executeMany(sql: string, paramsList: unknown[][]): { totalAffected: number;
|
|
263
|
+
executeMany(sql: string, paramsList: unknown[][]): { totalAffected: number; lastId?: number | bigint } {
|
|
264
264
|
throw new Error("Use executeManyAsync() for Firebird — async adapter requires async methods.");
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
async executeManyAsync(sql: string, paramsList: unknown[][]): Promise<{ totalAffected: number;
|
|
267
|
+
async executeManyAsync(sql: string, paramsList: unknown[][]): Promise<{ totalAffected: number; lastId?: number | bigint }> {
|
|
268
268
|
let totalAffected = 0;
|
|
269
269
|
for (const params of paramsList) {
|
|
270
270
|
await this.executeAsync(sql, params);
|
|
@@ -333,16 +333,16 @@ export class FirebirdAdapter implements DatabaseAdapter {
|
|
|
333
333
|
// the batch reports affectedRows == row count and no lastInsertId (same as the
|
|
334
334
|
// single-row path). See PostgresAdapter for the array-crash rationale.
|
|
335
335
|
if (Array.isArray(data)) {
|
|
336
|
-
if (data.length === 0) return { success: true,
|
|
336
|
+
if (data.length === 0) return { success: true, affectedRows: 0 };
|
|
337
337
|
const keys = Object.keys(data[0]);
|
|
338
338
|
const placeholders = keys.map(() => "?").join(", ");
|
|
339
339
|
const sql = `INSERT INTO "${table}" ("${keys.join('", "')}") VALUES (${placeholders})`;
|
|
340
340
|
const paramsList = data.map((row) => keys.map((k) => row[k]));
|
|
341
341
|
try {
|
|
342
342
|
const result = await this.executeManyAsync(sql, paramsList);
|
|
343
|
-
return { success: true,
|
|
343
|
+
return { success: true, affectedRows: result.totalAffected, lastId: result.lastId };
|
|
344
344
|
} catch (e) {
|
|
345
|
-
return { success: false,
|
|
345
|
+
return { success: false, affectedRows: 0, error: (e as Error).message };
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
|
|
@@ -356,10 +356,10 @@ export class FirebirdAdapter implements DatabaseAdapter {
|
|
|
356
356
|
// Firebird doesn't have a generic last_insert_id — return success without id
|
|
357
357
|
return {
|
|
358
358
|
success: true,
|
|
359
|
-
|
|
359
|
+
affectedRows: 1,
|
|
360
360
|
};
|
|
361
361
|
} catch (e) {
|
|
362
|
-
return { success: false,
|
|
362
|
+
return { success: false, affectedRows: 0, error: (e as Error).message };
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
365
|
|
|
@@ -376,9 +376,9 @@ export class FirebirdAdapter implements DatabaseAdapter {
|
|
|
376
376
|
|
|
377
377
|
try {
|
|
378
378
|
await this.executePromise(sql, values);
|
|
379
|
-
return { success: true,
|
|
379
|
+
return { success: true, affectedRows: 1 };
|
|
380
380
|
} catch (e) {
|
|
381
|
-
return { success: false,
|
|
381
|
+
return { success: false, affectedRows: 0, error: (e as Error).message };
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
384
|
|
|
@@ -394,9 +394,9 @@ export class FirebirdAdapter implements DatabaseAdapter {
|
|
|
394
394
|
|
|
395
395
|
try {
|
|
396
396
|
await this.executePromise(sql, values);
|
|
397
|
-
return { success: true,
|
|
397
|
+
return { success: true, affectedRows: 1 };
|
|
398
398
|
} catch (e) {
|
|
399
|
-
return { success: false,
|
|
399
|
+
return { success: false, affectedRows: 0, error: (e as Error).message };
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
402
|
|