@mikro-orm/core 7.2.2-dev.12 → 7.2.2-dev.14

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
@@ -1110,7 +1110,18 @@ export class EntityManager {
1110
1110
  const ret = [];
1111
1111
  for (const idx of shapes.values()) {
1112
1112
  const res = await this.upsertMany(entityName, idx.map(i => data[i]), options);
1113
- idx.forEach((i, j) => (ret[i] = res[j]));
1113
+ const seen = new Set();
1114
+ let j = 0;
1115
+ // `res` holds every entity once, so skip the rows resolving to an entity an earlier row already took
1116
+ for (const i of idx) {
1117
+ const row = data[i];
1118
+ const entity = Utils.isEntity(row)
1119
+ ? row
1120
+ : em.#unitOfWork.tryGetById(entityName, row, options.schema, false);
1121
+ if (!seen.has(entity)) {
1122
+ seen.add((ret[i] = res[j++]));
1123
+ }
1124
+ }
1114
1125
  }
1115
1126
  // rows resolving to the same entity are returned once, as in the single statement path
1116
1127
  return [...new Set(ret.filter(entity => entity))];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.2.2-dev.12",
3
+ "version": "7.2.2-dev.14",
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",
@@ -111,9 +111,17 @@ export class QueryHelper {
111
111
  const op = this.liftGroupOperators(value, prop.targetMeta, metadata, k);
112
112
  if (op) {
113
113
  delete where[k];
114
- where[op] = value[op].map((v) => {
114
+ const group = value[op].map((v) => {
115
115
  return { [k]: v };
116
116
  });
117
+ if (op in where) {
118
+ // Sibling groups are conjunctive, even when both use `$or`.
119
+ where.$and ??= [];
120
+ where.$and.push({ [op]: group });
121
+ }
122
+ else {
123
+ where[op] = group;
124
+ }
117
125
  }
118
126
  }
119
127
  return undefined;
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.12';
156
+ static #ORM_VERSION = '7.2.2-dev.14';
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}`;