@mikro-orm/mysql 7.2.7-dev.1 → 7.2.7-dev.10

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Configuration, Constructor, EntityDictionary, EntityName, FilterQuery, NativeInsertUpdateManyOptions, QueryResult, UpsertManyOptions } from '@mikro-orm/core';
1
+ import { type Configuration, type Constructor, type EntityDictionary, type EntityName, type FilterQuery, type NativeInsertUpdateManyOptions, type QueryResult, type UpsertManyOptions } from '@mikro-orm/core';
2
2
  import { AbstractSqlDriver } from '@mikro-orm/sql';
3
3
  import { MySqlConnection } from './MySqlConnection.js';
4
4
  import { MySqlMikroORM } from './MySqlMikroORM.js';
package/MySqlDriver.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { isRaw, } from '@mikro-orm/core';
1
2
  import { AbstractSqlDriver, Utils } from '@mikro-orm/sql';
2
3
  import { MySqlConnection } from './MySqlConnection.js';
3
4
  import { MySqlMikroORM } from './MySqlMikroORM.js';
@@ -28,6 +29,7 @@ export class MySqlDriver extends AbstractSqlDriver {
28
29
  const rest = await this.nativeInsertMany(entityName, data.slice(split), options);
29
30
  res.rows.push(...rest.rows);
30
31
  res.affectedRows += rest.affectedRows;
32
+ res.insertedIds = res.insertedIds && rest.insertedIds ? [...res.insertedIds, ...rest.insertedIds] : undefined;
31
33
  return res;
32
34
  }
33
35
  const res = await super.nativeInsertMany(entityName, data, options);
@@ -36,6 +38,11 @@ export class MySqlDriver extends AbstractSqlDriver {
36
38
  const autoIncrementIncrement = await this.getAutoIncrementIncrement(ctx);
37
39
  data.forEach((item, idx) => (res.rows[idx] = { [pks[0]]: item[pk] ?? res.insertId + idx * autoIncrementIncrement }));
38
40
  res.row = res.rows[0];
41
+ const ids = res.rows.map(row => row[pks[0]]);
42
+ // without `returning` the value of a raw pk expression is never known
43
+ if (pks.length === 1 && !ids.some(isRaw)) {
44
+ res.insertedIds = ids;
45
+ }
39
46
  return res;
40
47
  }
41
48
  async nativeUpdateMany(entityName, where, data, options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/mysql",
3
- "version": "7.2.7-dev.1",
3
+ "version": "7.2.7-dev.10",
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.7-dev.1",
50
+ "@mikro-orm/sql": "7.2.7-dev.10",
51
51
  "kysely": "0.29.8",
52
52
  "mysql2": "3.24.6",
53
53
  "sqlstring": "2.3.3"
@@ -56,7 +56,7 @@
56
56
  "@mikro-orm/core": "^7.2.6"
57
57
  },
58
58
  "peerDependencies": {
59
- "@mikro-orm/core": "7.2.7-dev.1"
59
+ "@mikro-orm/core": "7.2.7-dev.10"
60
60
  },
61
61
  "engines": {
62
62
  "node": ">= 22.17.0"