@mikro-orm/mariadb 6.2.10-dev.7 → 6.2.10-dev.71

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.
@@ -1,4 +1,4 @@
1
- import { type AnyEntity, type Configuration, type ConnectionType, type EntityDictionary, type LoggingOptions, type NativeInsertUpdateManyOptions, type QueryResult, type Transaction } from '@mikro-orm/core';
1
+ import { type AnyEntity, type Configuration, type ConnectionType, type EntityDictionary, type LoggingOptions, type NativeInsertUpdateManyOptions, type QueryResult, type Transaction, type FilterQuery, type UpsertManyOptions } from '@mikro-orm/core';
2
2
  import { AbstractSqlDriver, type Knex, type SqlEntityManager } from '@mikro-orm/knex';
3
3
  import { MariaDbConnection } from './MariaDbConnection';
4
4
  import { MariaDbPlatform } from './MariaDbPlatform';
@@ -8,5 +8,6 @@ export declare class MariaDbDriver extends AbstractSqlDriver<MariaDbConnection,
8
8
  constructor(config: Configuration);
9
9
  private getAutoIncrementIncrement;
10
10
  nativeInsertMany<T extends object>(entityName: string, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
11
+ nativeUpdateMany<T extends object>(entityName: string, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T> & UpsertManyOptions<T>): Promise<QueryResult<T>>;
11
12
  createQueryBuilder<T extends AnyEntity<T>>(entityName: string, ctx?: Transaction<Knex.Transaction>, preferredConnectionType?: ConnectionType, convertCustomTypes?: boolean, loggerContext?: LoggingOptions, alias?: string, em?: SqlEntityManager): MariaDbQueryBuilder<T, any, any, any>;
12
13
  }
package/MariaDbDriver.js CHANGED
@@ -30,6 +30,27 @@ class MariaDbDriver extends knex_1.AbstractSqlDriver {
30
30
  res.row = res.rows[0];
31
31
  return res;
32
32
  }
33
+ async nativeUpdateMany(entityName, where, data, options = {}) {
34
+ const res = await super.nativeUpdateMany(entityName, where, data, options);
35
+ const pks = this.getPrimaryKeyFields(entityName);
36
+ const ctx = options.ctx;
37
+ const autoIncrementIncrement = await this.getAutoIncrementIncrement(ctx);
38
+ let i = 0;
39
+ const rows = where.map(cond => {
40
+ if (res.insertId != null && core_1.Utils.isEmpty(cond)) {
41
+ return { [pks[0]]: res.insertId + (i++ * autoIncrementIncrement) };
42
+ }
43
+ if (cond[pks[0]] == null) {
44
+ return undefined;
45
+ }
46
+ return { [pks[0]]: cond[pks[0]] };
47
+ });
48
+ if (rows.every(i => i !== undefined)) {
49
+ res.rows = rows;
50
+ }
51
+ res.row = res.rows[0];
52
+ return res;
53
+ }
33
54
  createQueryBuilder(entityName, ctx, preferredConnectionType, convertCustomTypes, loggerContext, alias, em) {
34
55
  // do not compute the connectionType if EM is provided as it will be computed from it in the QB later on
35
56
  const connectionType = em ? preferredConnectionType : this.resolveConnectionType({ ctx, connectionType: preferredConnectionType });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineMariaDbConfig = exports.MariaDbMikroORM = void 0;
3
+ exports.MariaDbMikroORM = void 0;
4
+ exports.defineMariaDbConfig = defineMariaDbConfig;
4
5
  const core_1 = require("@mikro-orm/core");
5
6
  const MariaDbDriver_1 = require("./MariaDbDriver");
6
7
  /**
@@ -26,4 +27,3 @@ exports.MariaDbMikroORM = MariaDbMikroORM;
26
27
  function defineMariaDbConfig(options) {
27
28
  return (0, core_1.defineConfig)({ driver: MariaDbDriver_1.MariaDbDriver, ...options });
28
29
  }
29
- exports.defineMariaDbConfig = defineMariaDbConfig;
@@ -48,7 +48,7 @@ class MariaDbSchemaHelper extends knex_1.MySqlSchemaHelper {
48
48
  nullif(table_schema, schema()) as schema_name,
49
49
  column_name as column_name,
50
50
  column_default as column_default,
51
- column_comment as column_comment,
51
+ nullif(column_comment, '') as column_comment,
52
52
  is_nullable as is_nullable,
53
53
  data_type as data_type,
54
54
  column_type as column_type,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/mariadb",
3
- "version": "6.2.10-dev.7",
3
+ "version": "6.2.10-dev.71",
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",
@@ -58,13 +58,13 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@mikro-orm/knex": "6.2.10-dev.7",
62
- "mariadb": "3.3.0"
61
+ "@mikro-orm/knex": "6.2.10-dev.71",
62
+ "mariadb": "3.3.1"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@mikro-orm/core": "^6.2.9"
66
66
  },
67
67
  "peerDependencies": {
68
- "@mikro-orm/core": "6.2.10-dev.7"
68
+ "@mikro-orm/core": "6.2.10-dev.71"
69
69
  }
70
70
  }