@mikro-orm/core 6.3.13-dev.7 → 6.3.13-dev.9

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/MikroORM.d.ts CHANGED
@@ -66,7 +66,7 @@ export declare class MikroORM<D extends IDatabaseDriver = IDatabaseDriver, EM ex
66
66
  /**
67
67
  * Allows dynamically discovering new entity by reference, handy for testing schema diffing.
68
68
  */
69
- discoverEntity<T extends Constructor | EntitySchema>(entities: T | T[]): void;
69
+ discoverEntity<T extends Constructor | EntitySchema>(entities: T | T[], reset?: string | string[]): void;
70
70
  /**
71
71
  * Gets the SchemaGenerator.
72
72
  */
package/MikroORM.js CHANGED
@@ -186,8 +186,12 @@ class MikroORM {
186
186
  /**
187
187
  * Allows dynamically discovering new entity by reference, handy for testing schema diffing.
188
188
  */
189
- discoverEntity(entities) {
189
+ discoverEntity(entities, reset) {
190
190
  entities = utils_1.Utils.asArray(entities);
191
+ for (const className of utils_1.Utils.asArray(reset)) {
192
+ this.metadata.reset(className);
193
+ this.discovery.reset(className);
194
+ }
191
195
  const tmp = this.discovery.discoverReferences(entities);
192
196
  const options = this.config.get('discovery');
193
197
  new metadata_1.MetadataValidator().validateDiscovered([...Object.values(this.metadata.getAll()), ...tmp], options);
@@ -24,6 +24,7 @@ export declare class MetadataDiscovery {
24
24
  private tryDiscoverTargets;
25
25
  private discoverDirectories;
26
26
  discoverReferences<T>(refs: (Constructor<T> | EntitySchema<T>)[]): EntityMetadata<T>[];
27
+ reset(className: string): void;
27
28
  private prepare;
28
29
  private getSchema;
29
30
  private discoverEntity;
@@ -242,6 +242,13 @@ class MetadataDiscovery {
242
242
  }
243
243
  return this.discovered.filter(meta => found.find(m => m.name === meta.className));
244
244
  }
245
+ reset(className) {
246
+ const exists = this.discovered.findIndex(m => m.className === className);
247
+ if (exists !== -1) {
248
+ this.metadata.reset(this.discovered[exists].className);
249
+ this.discovered.splice(exists, 1);
250
+ }
251
+ }
245
252
  prepare(entity) {
246
253
  if ('schema' in entity && entity.schema instanceof EntitySchema_1.EntitySchema) {
247
254
  return entity.schema;
@@ -1132,7 +1139,12 @@ class MetadataDiscovery {
1132
1139
  }
1133
1140
  }
1134
1141
  if (prop.kind === enums_1.ReferenceKind.SCALAR && !(mappedType instanceof types_1.UnknownType)) {
1135
- prop.columnTypes ??= [mappedType.getColumnType(prop, this.platform)];
1142
+ if (!prop.columnTypes && prop.nativeEnumName && meta.schema !== this.platform.getDefaultSchemaName() && meta.schema && !prop.nativeEnumName.includes('.')) {
1143
+ prop.columnTypes = [`${meta.schema}.${prop.nativeEnumName}`];
1144
+ }
1145
+ else {
1146
+ prop.columnTypes ??= [mappedType.getColumnType(prop, this.platform)];
1147
+ }
1136
1148
  // use only custom types provided by user, we don't need to use the ones provided by ORM,
1137
1149
  // with exception for ArrayType and JsonType, those two are handled in
1138
1150
  if (!Object.values(types_1.t).some(type => type === mappedType.constructor)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.3.13-dev.7",
3
+ "version": "6.3.13-dev.9",
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",
@@ -64,7 +64,7 @@
64
64
  "esprima": "4.0.1",
65
65
  "fs-extra": "11.2.0",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.3.13-dev.7",
67
+ "mikro-orm": "6.3.13-dev.9",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -401,7 +401,9 @@ class EntityComparator {
401
401
  }
402
402
  return true;
403
403
  }
404
- ret += meta.props.filter(p => p.embedded?.[0] === prop.name).map(childProp => {
404
+ ret += meta.props.filter(p => p.embedded?.[0] === prop.name
405
+ // object for JSON embeddable
406
+ && (p.object || (p.persist !== false))).map(childProp => {
405
407
  const childDataKey = meta.embeddable || prop.object ? dataKey + this.wrap(childProp.embedded[1]) : this.wrap(childProp.name);
406
408
  const childEntityKey = [...path, childProp.embedded[1]].map(k => this.wrap(k)).join('');
407
409
  const childCond = `typeof entity${childEntityKey} !== 'undefined'`;