@mikro-orm/mysql 7.2.6-dev.20 → 7.2.6-dev.22
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/MySqlDriver.js +12 -2
- package/package.json +3 -3
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.22",
|
|
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,7 +47,7 @@
|
|
|
47
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@mikro-orm/sql": "7.2.6-dev.
|
|
50
|
+
"@mikro-orm/sql": "7.2.6-dev.22",
|
|
51
51
|
"kysely": "0.29.7",
|
|
52
52
|
"mysql2": "3.24.6",
|
|
53
53
|
"sqlstring": "2.3.3"
|
|
@@ -56,7 +56,7 @@
|
|
|
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.22"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">= 22.17.0"
|