@mikro-orm/knex 6.4.1-dev.1 → 6.4.1-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.
@@ -10,7 +10,7 @@ export declare class PivotCollectionPersister<Entity extends object> {
10
10
  private readonly deletes;
11
11
  private readonly batchSize;
12
12
  private order;
13
- constructor(meta: EntityMetadata<Entity>, driver: AbstractSqlDriver, ctx?: Transaction, schema?: string | undefined);
13
+ constructor(meta: EntityMetadata<Entity>, driver: AbstractSqlDriver, ctx?: Transaction | undefined, schema?: string | undefined);
14
14
  enqueueUpdate(prop: EntityProperty<Entity>, insertDiff: Primary<Entity>[][], deleteDiff: Primary<Entity>[][] | boolean, pks: Primary<Entity>[]): void;
15
15
  private enqueueInsert;
16
16
  private enqueueDelete;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.4.1-dev.1",
3
+ "version": "6.4.1-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
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -66,7 +66,7 @@
66
66
  "@mikro-orm/core": "^6.4.0"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.4.1-dev.1",
69
+ "@mikro-orm/core": "6.4.1-dev.10",
70
70
  "better-sqlite3": "*",
71
71
  "libsql": "*",
72
72
  "mariadb": "*"
@@ -529,7 +529,7 @@ class QueryBuilder {
529
529
  core_1.Utils.runIfNotEmpty(() => qb.offset(this._offset), this._offset);
530
530
  core_1.Utils.runIfNotEmpty(() => this._comments.forEach(comment => qb.comment(comment)), this._comments);
531
531
  core_1.Utils.runIfNotEmpty(() => this._hintComments.forEach(comment => qb.hintComment(comment)), this._hintComments);
532
- core_1.Utils.runIfNotEmpty(() => this.helper.appendOnConflictClause(type, this._onConflict, qb), this._onConflict);
532
+ core_1.Utils.runIfNotEmpty(() => this.helper.appendOnConflictClause(enums_1.QueryType.UPSERT, this._onConflict, qb), this._onConflict);
533
533
  if (this.type === enums_1.QueryType.TRUNCATE && this.platform.usesCascadeStatement()) {
534
534
  return this._query.qb = this.knex.raw(qb.toSQL().toNative().sql + ' cascade');
535
535
  }
@@ -768,6 +768,7 @@ class QueryBuilder {
768
768
  case enums_1.QueryType.INSERT:
769
769
  case enums_1.QueryType.UPDATE:
770
770
  case enums_1.QueryType.DELETE:
771
+ case enums_1.QueryType.UPSERT:
771
772
  case enums_1.QueryType.TRUNCATE:
772
773
  return this.execute('run').then(onfulfilled, onrejected);
773
774
  case enums_1.QueryType.COUNT:
@@ -93,7 +93,7 @@ class QueryBuilderHelper {
93
93
  }
94
94
  return this.knex.raw(`${value}${as}`);
95
95
  }
96
- if (prop?.hasConvertToJSValueSQL) {
96
+ if (prop?.hasConvertToJSValueSQL && type !== enums_1.QueryType.UPSERT) {
97
97
  let valueSQL;
98
98
  if (prop.fieldNames.length > 1 && fkIdx !== -1) {
99
99
  const fk = prop.targetMeta.getPrimaryProps()[fkIdx];
@@ -736,7 +736,7 @@ class QueryBuilderHelper {
736
736
  const meta = this.metadata.get(this.entityName);
737
737
  const tableName = this.driver.getTableName(meta, { schema }, false);
738
738
  for (const key of Object.keys(cond)) {
739
- const mapped = this.mapper(key, enums_1.QueryType.INSERT);
739
+ const mapped = this.mapper(key, enums_1.QueryType.UPSERT);
740
740
  core_1.Utils.renameKey(cond, key, tableName + '.' + mapped);
741
741
  }
742
742
  return cond;
package/query/enums.d.ts CHANGED
@@ -4,7 +4,8 @@ export declare enum QueryType {
4
4
  COUNT = "COUNT",
5
5
  INSERT = "INSERT",
6
6
  UPDATE = "UPDATE",
7
- DELETE = "DELETE"
7
+ DELETE = "DELETE",
8
+ UPSERT = "UPSERT"
8
9
  }
9
10
  export declare enum JoinType {
10
11
  leftJoin = "left join",
package/query/enums.js CHANGED
@@ -9,6 +9,7 @@ var QueryType;
9
9
  QueryType["INSERT"] = "INSERT";
10
10
  QueryType["UPDATE"] = "UPDATE";
11
11
  QueryType["DELETE"] = "DELETE";
12
+ QueryType["UPSERT"] = "UPSERT";
12
13
  })(QueryType || (exports.QueryType = QueryType = {}));
13
14
  var JoinType;
14
15
  (function (JoinType) {