@mikro-orm/knex 6.0.0-dev.110 → 6.0.0-dev.111

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.
@@ -290,7 +290,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
290
290
  async nativeInsertMany(entityName, data, options = {}) {
291
291
  options.processCollections ??= true;
292
292
  options.convertCustomTypes ??= true;
293
- const meta = this.metadata.find(entityName);
293
+ const meta = this.metadata.find(entityName)?.root;
294
294
  const collections = options.processCollections ? data.map(d => this.extractManyToMany(entityName, d)) : [];
295
295
  const pks = this.getPrimaryKeyFields(entityName);
296
296
  const set = new Set();
@@ -322,24 +322,31 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
322
322
  if (fields.length > 0 || this.platform.usesDefaultKeyword()) {
323
323
  sql += data.map(row => {
324
324
  const keys = [];
325
+ const usedDups = [];
325
326
  props.forEach(prop => {
326
327
  if (prop.fieldNames.length > 1) {
327
328
  const param = core_1.Utils.flatten([...row[prop.name] ?? prop.fieldNames.map(() => null)]);
328
329
  const key = param.map(() => '?');
329
330
  prop.fieldNames.forEach((field, idx) => {
330
- if (!duplicates.includes(field)) {
331
+ if (!duplicates.includes(field) || !usedDups.includes(field)) {
331
332
  params.push(param[idx]);
332
333
  keys.push(key[idx]);
334
+ usedDups.push(field);
333
335
  }
334
336
  });
335
337
  }
336
- else if (prop.customType && 'convertToDatabaseValueSQL' in prop.customType && !this.platform.isRaw(row[prop.name])) {
337
- keys.push(prop.customType.convertToDatabaseValueSQL('?', this.platform));
338
- addParams(prop, row);
339
- }
340
338
  else {
341
- addParams(prop, row);
342
- keys.push('?');
339
+ const field = prop.fieldNames[0];
340
+ if (!duplicates.includes(field) || !usedDups.includes(field)) {
341
+ if (prop.customType && 'convertToDatabaseValueSQL' in prop.customType && !this.platform.isRaw(row[prop.name])) {
342
+ keys.push(prop.customType.convertToDatabaseValueSQL('?', this.platform));
343
+ }
344
+ else {
345
+ keys.push('?');
346
+ }
347
+ addParams(prop, row);
348
+ usedDups.push(field);
349
+ }
343
350
  }
344
351
  });
345
352
  return '(' + (keys.join(', ') || 'default') + ')';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.0.0-dev.110",
3
+ "version": "6.0.0-dev.111",
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
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -66,6 +66,6 @@
66
66
  "@mikro-orm/core": "^5.8.5"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.0.0-dev.110"
69
+ "@mikro-orm/core": "6.0.0-dev.111"
70
70
  }
71
71
  }
@@ -33,7 +33,7 @@ class DatabaseTable {
33
33
  delete this.columns[name];
34
34
  }
35
35
  getIndexes() {
36
- return this.indexes;
36
+ return core_1.Utils.removeDuplicates(this.indexes);
37
37
  }
38
38
  getChecks() {
39
39
  return this.checks;