@mikro-orm/core 7.2.9-dev.0 → 7.2.9-dev.2

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
@@ -1318,7 +1318,7 @@ export class EntityManager {
1318
1318
  // an empty condition identifies no row, it must not turn into a reload condition matching every row
1319
1319
  const getRowUniqueFields = (where) => Utils.isPlainObject(where) && !Utils.hasObjectKeys(where) ? uniqueFields : getUniqueFields(where);
1320
1320
  const platform = this.getPlatform();
1321
- const returning = getOnConflictReturningFields(meta, data[dataIndexes[0]], uniqueFields, options, platform);
1321
+ const returning = getOnConflictReturningFields(meta, allData[0], uniqueFields, options, platform);
1322
1322
  if (options.onConflictWhere && res.rows?.length !== allData.length) {
1323
1323
  returning.push(...meta.comparableProps.filter(p => !p.lazy && !p.embeddable).map(p => p.name));
1324
1324
  }
@@ -2399,7 +2399,17 @@ export class EntityManager {
2399
2399
  }
2400
2400
  let autoRefresh;
2401
2401
  if (options.fields) {
2402
- autoRefresh = options.fields.some(field => !helper(entity).__loadedProperties.has(field));
2402
+ // inline embeddables track only their leaf properties as loaded, not the parent
2403
+ const isLoaded = (prop) => helper(entity).__loadedProperties.has(prop.name) ||
2404
+ (prop.kind === ReferenceKind.EMBEDDED && !prop.object && Object.values(prop.embeddedProps).every(isLoaded));
2405
+ autoRefresh = options.fields.some(field => {
2406
+ const [first, ...rest] = field.split('.');
2407
+ let prop = meta.properties[first];
2408
+ for (const part of rest) {
2409
+ prop = prop?.kind === ReferenceKind.EMBEDDED && !prop.object ? prop.embeddedProps[part] : undefined;
2410
+ }
2411
+ return !prop || !isLoaded(prop);
2412
+ });
2403
2413
  }
2404
2414
  else {
2405
2415
  autoRefresh = meta.comparableProps.some(prop => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.2.9-dev.0",
3
+ "version": "7.2.9-dev.2",
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.9-dev.0';
156
+ static #ORM_VERSION = '7.2.9-dev.2';
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}`;