@mikro-orm/core 6.6.5-dev.0 → 6.6.5-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.d.ts +3 -2
- package/EntityManager.js +1 -0
- package/entity/Collection.js +1 -0
- package/metadata/MetadataDiscovery.js +5 -4
- package/package.json +2 -2
package/EntityManager.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type Configuration, Cursor } from './utils';
|
|
|
4
4
|
import { type AssignOptions, EntityFactory, EntityLoader, type EntityLoaderOptions, type EntityRepository, EntityValidator, Reference } from './entity';
|
|
5
5
|
import { UnitOfWork } from './unit-of-work';
|
|
6
6
|
import type { CountOptions, DeleteOptions, FilterOptions, FindAllOptions, FindByCursorOptions, FindOneOptions, FindOneOrFailOptions, FindOptions, GetReferenceOptions, IDatabaseDriver, LockOptions, NativeInsertUpdateOptions, UpdateOptions, UpsertManyOptions, UpsertOptions } from './drivers';
|
|
7
|
-
import type { AnyEntity, AnyString, ArrayElement, AutoPath, ConnectionType, Dictionary, EntityData, EntityDictionary, EntityDTO, EntityMetadata, EntityName, FilterDef, FilterQuery, FromEntityType, GetRepository, IHydrator, IsSubset, Loaded, MaybePromise, MergeLoaded, MergeSelected, NoInfer, ObjectQuery, Primary, Ref, RequiredEntityData, UnboxArray } from './typings';
|
|
7
|
+
import type { AnyEntity, AnyString, ArrayElement, AutoPath, ConnectionType, Dictionary, EntityData, EntityDictionary, EntityDTO, EntityMetadata, EntityName, FilterDef, FilterQuery, FromEntityType, GetRepository, IHydrator, IsSubset, Loaded, MaybePromise, MergeLoaded, MergeSelected, NoInfer, ObjectQuery, PopulateOptions, Primary, Ref, RequiredEntityData, UnboxArray } from './typings';
|
|
8
8
|
import { FlushMode, LockMode, PopulatePath, type TransactionOptions } from './enums';
|
|
9
9
|
import type { MetadataStorage } from './metadata';
|
|
10
10
|
import type { Transaction } from './connections';
|
|
@@ -506,7 +506,8 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
506
506
|
private checkLockRequirements;
|
|
507
507
|
private lockAndPopulate;
|
|
508
508
|
private buildFields;
|
|
509
|
-
|
|
509
|
+
/** @internal */
|
|
510
|
+
preparePopulate<Entity extends object>(entityName: string, options: Pick<FindOptions<Entity, any, any>, 'populate' | 'strategy' | 'fields' | 'flags' | 'filters'>, validate?: boolean): Promise<PopulateOptions<Entity>[]>;
|
|
510
511
|
/**
|
|
511
512
|
* when the entity is found in identity map, we check if it was partially loaded or we are trying to populate
|
|
512
513
|
* some additional lazy properties, if so, we reload and merge the data from database
|
package/EntityManager.js
CHANGED
package/entity/Collection.js
CHANGED
|
@@ -85,6 +85,7 @@ class Collection extends ArrayCollection_1.ArrayCollection {
|
|
|
85
85
|
opts.orderBy = this.createOrderBy(opts.orderBy);
|
|
86
86
|
let items;
|
|
87
87
|
if (this.property.kind === enums_1.ReferenceKind.MANY_TO_MANY && em.getPlatform().usesPivotTable()) {
|
|
88
|
+
options.populate = await em.preparePopulate(this.property.type, options);
|
|
88
89
|
const cond = await em.applyFilters(this.property.type, where, options.filters ?? {}, 'read');
|
|
89
90
|
const map = await em.getDriver().loadFromPivotTable(this.property, [(0, wrap_1.helper)(this.owner).__primaryKeys], cond, opts.orderBy, ctx, options);
|
|
90
91
|
items = map[(0, wrap_1.helper)(this.owner).getSerializedPrimaryKey()].map((item) => em.merge(this.property.type, item, { convertCustomTypes: true }));
|
|
@@ -974,7 +974,8 @@ class MetadataDiscovery {
|
|
|
974
974
|
let i = 1;
|
|
975
975
|
Object.values(meta.properties).forEach(prop => {
|
|
976
976
|
const newProp = { ...prop };
|
|
977
|
-
|
|
977
|
+
const rootProp = meta.root.properties[prop.name];
|
|
978
|
+
if (rootProp && (rootProp.type !== prop.type || (rootProp.fieldNames && prop.fieldNames && !(0, Utils_1.compareArrays)(rootProp.fieldNames, prop.fieldNames)))) {
|
|
978
979
|
const name = newProp.name;
|
|
979
980
|
this.initFieldName(newProp, newProp.object);
|
|
980
981
|
newProp.name = name + '_' + (i++);
|
|
@@ -985,11 +986,11 @@ class MetadataDiscovery {
|
|
|
985
986
|
newProp.inherited = true;
|
|
986
987
|
return;
|
|
987
988
|
}
|
|
988
|
-
if (prop.enum && prop.items &&
|
|
989
|
-
newProp.items = Utils_1.Utils.unique([...
|
|
989
|
+
if (prop.enum && prop.items && rootProp?.items) {
|
|
990
|
+
newProp.items = Utils_1.Utils.unique([...rootProp.items, ...prop.items]);
|
|
990
991
|
}
|
|
991
992
|
newProp.nullable = true;
|
|
992
|
-
newProp.inherited = !
|
|
993
|
+
newProp.inherited = !rootProp;
|
|
993
994
|
meta.root.addProperty(newProp);
|
|
994
995
|
});
|
|
995
996
|
meta.collection = meta.root.collection;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.6.5-dev.
|
|
3
|
+
"version": "6.6.5-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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"esprima": "4.0.1",
|
|
65
65
|
"fs-extra": "11.3.3",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.6.5-dev.
|
|
67
|
+
"mikro-orm": "6.6.5-dev.2",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|