@mikro-orm/core 7.2.2-dev.2 → 7.2.2-dev.4

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/EntityManager.js CHANGED
@@ -995,6 +995,9 @@ export class EntityManager {
995
995
  const uniqueFields = options.onConflictFields ??
996
996
  (Utils.isPlainObject(where) ? Object.keys(where) : meta.primaryKeys);
997
997
  const returning = getOnConflictReturningFields(meta, data, uniqueFields, options);
998
+ if (options.onConflictWhere && !ret.row) {
999
+ returning.push(...Object.keys(data));
1000
+ }
998
1001
  if (options.onConflictAction === 'ignore' ||
999
1002
  !helper(entity).hasPrimaryKey() ||
1000
1003
  (returning.length > 0 && !(this.getPlatform().usesReturningStatement() && ret.row))) {
@@ -1183,9 +1186,9 @@ export class EntityManager {
1183
1186
  entitiesByData.clear();
1184
1187
  const loadPK = new Map();
1185
1188
  allData.forEach((row, i) => {
1186
- em.#unitOfWork
1187
- .getChangeSetPersister()
1188
- .mapReturnedValues(Utils.isEntity(data[i]) ? data[i] : null, Utils.isEntity(data[i]) ? {} : data[i], res.rows?.[i], meta, true);
1189
+ em.#unitOfWork.getChangeSetPersister().mapReturnedValues(Utils.isEntity(data[i]) ? data[i] : null, Utils.isEntity(data[i]) ? {} : data[i],
1190
+ // A suppressed conflict omits its row; positional mapping would hydrate a different entity.
1191
+ res.rows?.length === allData.length ? res.rows[i] : undefined, meta, true);
1189
1192
  const entity = Utils.isEntity(data[i])
1190
1193
  ? data[i]
1191
1194
  : em.#entityFactory.create(entityName, row, {
@@ -1204,6 +1207,9 @@ export class EntityManager {
1204
1207
  // oxfmt-ignore
1205
1208
  const uniqueFields = options.onConflictFields ?? (Utils.isPlainObject(allWhere[0]) ? Object.keys(allWhere[0]).flatMap(key => Utils.splitPrimaryKeys(key)) : meta.primaryKeys);
1206
1209
  const returning = getOnConflictReturningFields(meta, data[0], uniqueFields, options);
1210
+ if (options.onConflictWhere && res.rows?.length !== allData.length) {
1211
+ returning.push(...meta.comparableProps.filter(p => !p.lazy && !p.embeddable).map(p => p.name));
1212
+ }
1207
1213
  const reloadFields = returning.length > 0 && !(this.getPlatform().usesReturningStatement() && res.rows?.length === data.length);
1208
1214
  if (options.onConflictAction === 'ignore' || (!res.rows?.length && loadPK.size > 0) || reloadFields) {
1209
1215
  const unique = meta.hydrateProps.filter(p => !p.lazy).map(p => p.name);
@@ -1235,8 +1241,9 @@ export class EntityManager {
1235
1241
  const row = data2.find(row => {
1236
1242
  const tmp = {};
1237
1243
  add.forEach(k => {
1238
- if (!meta.properties[k]?.primary) {
1239
- tmp[k] = row[k];
1244
+ const prop = meta.properties[k];
1245
+ if (!prop?.primary) {
1246
+ tmp[k] = prop?.customType ? prop.customType.convertToDatabaseValue(row[k], this.getPlatform()) : row[k];
1240
1247
  }
1241
1248
  });
1242
1249
  return this.#comparator.matching(entityName, cond, tmp);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.2.2-dev.2",
3
+ "version": "7.2.2-dev.4",
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",
package/utils/Utils.js CHANGED
@@ -153,7 +153,7 @@ export function parseJsonSafe(value) {
153
153
  /** Collection of general-purpose utility methods used throughout the ORM. */
154
154
  export class Utils {
155
155
  static PK_SEPARATOR = '~~~';
156
- static #ORM_VERSION = '7.2.2-dev.2';
156
+ static #ORM_VERSION = '7.2.2-dev.4';
157
157
  /** Default session variable name backing an RLS filter argument (`current_setting('mikro.<filter>.<arg>')`). */
158
158
  static getRlsSettingName(filterName, argName) {
159
159
  return `mikro.${filterName}.${argName}`;