@mikro-orm/mysql 7.2.6-dev.2 → 7.2.6-dev.21
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/MySqlConnection.js +3 -0
- package/MySqlDriver.js +12 -2
- package/package.json +5 -5
package/MySqlConnection.js
CHANGED
|
@@ -138,6 +138,9 @@ export class MySqlConnection extends AbstractSqlConnection {
|
|
|
138
138
|
}
|
|
139
139
|
async commit(ctx, eventBroadcaster) {
|
|
140
140
|
if (!ctx.isRolledBack && 'savepointName' in ctx) {
|
|
141
|
+
if ('failedSavepointRollback' in ctx) {
|
|
142
|
+
throw ctx.failedSavepointRollback;
|
|
143
|
+
}
|
|
141
144
|
try {
|
|
142
145
|
await ctx.releaseSavepoint(ctx.savepointName).execute();
|
|
143
146
|
}
|
package/MySqlDriver.js
CHANGED
|
@@ -19,12 +19,22 @@ export class MySqlDriver extends AbstractSqlDriver {
|
|
|
19
19
|
}
|
|
20
20
|
async nativeInsertMany(entityName, data, options = {}) {
|
|
21
21
|
options.processCollections ??= true;
|
|
22
|
-
const res = await super.nativeInsertMany(entityName, data, options);
|
|
23
22
|
const meta = this.metadata.get(entityName);
|
|
23
|
+
const pk = meta.primaryKeys[0];
|
|
24
|
+
// mysql continues auto_increment from an explicit id, so a generated row after one starts a new insert
|
|
25
|
+
const split = data.findIndex((item, idx) => idx > 0 && item[pk] == null && data[idx - 1][pk] != null);
|
|
26
|
+
if (split > 0) {
|
|
27
|
+
const res = await this.nativeInsertMany(entityName, data.slice(0, split), options);
|
|
28
|
+
const rest = await this.nativeInsertMany(entityName, data.slice(split), options);
|
|
29
|
+
res.rows.push(...rest.rows);
|
|
30
|
+
res.affectedRows += rest.affectedRows;
|
|
31
|
+
return res;
|
|
32
|
+
}
|
|
33
|
+
const res = await super.nativeInsertMany(entityName, data, options);
|
|
24
34
|
const pks = this.getPrimaryKeyFields(meta);
|
|
25
35
|
const ctx = options.ctx;
|
|
26
36
|
const autoIncrementIncrement = await this.getAutoIncrementIncrement(ctx);
|
|
27
|
-
data.forEach((item, idx) => (res.rows[idx] = { [pks[0]]: item[
|
|
37
|
+
data.forEach((item, idx) => (res.rows[idx] = { [pks[0]]: item[pk] ?? res.insertId + idx * autoIncrementIncrement }));
|
|
28
38
|
res.row = res.rows[0];
|
|
29
39
|
return res;
|
|
30
40
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/mysql",
|
|
3
|
-
"version": "7.2.6-dev.
|
|
3
|
+
"version": "7.2.6-dev.21",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -47,16 +47,16 @@
|
|
|
47
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@mikro-orm/sql": "7.2.6-dev.
|
|
51
|
-
"kysely": "0.29.
|
|
52
|
-
"mysql2": "3.24.
|
|
50
|
+
"@mikro-orm/sql": "7.2.6-dev.21",
|
|
51
|
+
"kysely": "0.29.7",
|
|
52
|
+
"mysql2": "3.24.6",
|
|
53
53
|
"sqlstring": "2.3.3"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@mikro-orm/core": "^7.2.5"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@mikro-orm/core": "7.2.6-dev.
|
|
59
|
+
"@mikro-orm/core": "7.2.6-dev.21"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">= 22.17.0"
|