@mikro-orm/core 6.6.8-dev.2 → 6.6.8-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
@@ -1160,7 +1160,7 @@ class EntityManager {
1160
1160
  const data = this.driver.mapResult(result, meta);
1161
1161
  Object.keys(data).forEach(k => {
1162
1162
  const prop = meta.properties[k];
1163
- if (prop && prop.kind === enums_1.ReferenceKind.SCALAR && enums_1.SCALAR_TYPES.includes(prop.runtimeType) && !prop.customType && (prop.setter || !prop.getter)) {
1163
+ if (prop?.kind === enums_1.ReferenceKind.SCALAR && enums_1.SCALAR_TYPES.includes(prop.runtimeType) && !prop.customType && (prop.setter || !prop.getter)) {
1164
1164
  data[k] = this.validator.validateProperty(prop, data[k], data);
1165
1165
  }
1166
1166
  });
@@ -241,7 +241,7 @@ export interface PropertyOptions<Owner> {
241
241
  * }
242
242
  * ```
243
243
  */
244
- accessor?: keyof Owner | boolean;
244
+ accessor?: keyof Owner | AnyString | boolean;
245
245
  /**
246
246
  * Set to define serialized primary key for MongoDB. (virtual)
247
247
  * Alias for `@SerializedPrimaryKey()` decorator.
@@ -83,6 +83,7 @@ class MetadataDiscovery {
83
83
  }
84
84
  const desc = Object.getOwnPropertyDescriptor(meta.prototype, prop.name);
85
85
  if (desc?.get || desc?.set) {
86
+ this.initRelation(prop);
86
87
  this.initFieldName(prop);
87
88
  const accessor = prop.name;
88
89
  prop.name = typeof prop.accessor === 'string' ? prop.accessor : prop.name;
@@ -98,7 +99,10 @@ class MetadataDiscovery {
98
99
  }
99
100
  else {
100
101
  const name = prop.name;
101
- prop.name = prop.accessor;
102
+ if (prop.kind === enums_1.ReferenceKind.SCALAR || prop.kind === enums_1.ReferenceKind.EMBEDDED) {
103
+ prop.name = prop.accessor;
104
+ }
105
+ this.initRelation(prop);
102
106
  this.initFieldName(prop);
103
107
  prop.serializedName ??= prop.accessor;
104
108
  prop.name = name;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.6.8-dev.2",
3
+ "version": "6.6.8-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
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -60,11 +60,11 @@
60
60
  },
61
61
  "dependencies": {
62
62
  "dataloader": "2.2.3",
63
- "dotenv": "17.2.3",
63
+ "dotenv": "17.3.1",
64
64
  "esprima": "4.0.1",
65
65
  "fs-extra": "11.3.3",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.6.8-dev.2",
67
+ "mikro-orm": "6.6.8-dev.4",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -836,7 +836,7 @@ class UnitOfWork {
836
836
  if (Utils_1.Utils.isCollection(ref)) {
837
837
  ref.getItems(false).some(item => {
838
838
  const cs = this.changeSets.get(entity_1.Reference.unwrapReference(item));
839
- const isScheduledForInsert = cs && cs.type === ChangeSet_1.ChangeSetType.CREATE && !cs.persisted;
839
+ const isScheduledForInsert = cs?.type === ChangeSet_1.ChangeSetType.CREATE && !cs.persisted;
840
840
  if (isScheduledForInsert) {
841
841
  this.scheduleExtraUpdate(changeSet, [prop]);
842
842
  return true;
@@ -845,7 +845,7 @@ class UnitOfWork {
845
845
  });
846
846
  }
847
847
  const cs = this.changeSets.get(entity_1.Reference.unwrapReference(ref));
848
- const isScheduledForInsert = cs && cs.type === ChangeSet_1.ChangeSetType.CREATE && !cs.persisted;
848
+ const isScheduledForInsert = cs?.type === ChangeSet_1.ChangeSetType.CREATE && !cs.persisted;
849
849
  if (isScheduledForInsert) {
850
850
  this.scheduleExtraUpdate(changeSet, [prop]);
851
851
  }
package/utils/Utils.js CHANGED
@@ -433,7 +433,7 @@ class Utils {
433
433
  return true;
434
434
  }
435
435
  if (Utils.isObject(key)) {
436
- if (key.constructor && key.constructor.name.toLowerCase() === 'objectid') {
436
+ if (key.constructor?.name.toLowerCase() === 'objectid') {
437
437
  return true;
438
438
  }
439
439
  if (!Utils.isPlainObject(key) && !Utils.isEntity(key, true)) {
@@ -625,7 +625,7 @@ class Utils {
625
625
  * Checks whether the argument is ObjectId instance
626
626
  */
627
627
  static isObjectID(key) {
628
- return Utils.isObject(key) && key.constructor && key.constructor.name.toLowerCase() === 'objectid';
628
+ return Utils.isObject(key) && key.constructor?.name.toLowerCase() === 'objectid';
629
629
  }
630
630
  /**
631
631
  * Checks whether the argument is empty (array without items, object without keys or falsy value).