@mikro-orm/core 7.2.12-dev.16 → 7.2.12-dev.18
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/entity/Collection.d.ts +3 -3
- package/entity/Collection.js +12 -7
- package/entity/EntityHelper.d.ts +7 -2
- package/entity/EntityHelper.js +14 -7
- package/entity/WrappedEntity.d.ts +2 -3
- package/entity/WrappedEntity.js +1 -2
- package/hydration/Hydrator.d.ts +0 -3
- package/hydration/Hydrator.js +0 -11
- package/hydration/ObjectHydrator.js +20 -9
- package/package.json +1 -1
- package/typings.d.ts +0 -2
- package/typings.js +0 -9
- package/utils/Utils.js +1 -1
package/entity/Collection.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ export declare class Collection<T extends object, O extends object = object> {
|
|
|
97
97
|
/**
|
|
98
98
|
* @internal
|
|
99
99
|
*/
|
|
100
|
-
hydrate(items: T[], forcePropagate?: boolean, partial?: boolean, readonly?: boolean, count?: boolean): void;
|
|
100
|
+
hydrate(items: T[], forcePropagate?: boolean, partial?: boolean, readonly?: boolean, count?: boolean, hydration?: boolean): void;
|
|
101
101
|
/**
|
|
102
102
|
* Remove all items from the collection. Note that removing items from collection does not necessarily imply deleting the target entity,
|
|
103
103
|
* it means we are disconnecting the relation - removing items from collection, not removing entities from database - `Collection.remove()`
|
|
@@ -180,9 +180,9 @@ export declare class Collection<T extends object, O extends object = object> {
|
|
|
180
180
|
* @internal
|
|
181
181
|
*/
|
|
182
182
|
set property(prop: EntityProperty);
|
|
183
|
-
protected propagate(item: T, method: 'add' | 'remove' | 'takeSnapshot'): void;
|
|
183
|
+
protected propagate(item: T, method: 'add' | 'remove' | 'takeSnapshot', hydration?: boolean): void;
|
|
184
184
|
protected propagateToInverseSide(item: T, method: 'add' | 'remove' | 'takeSnapshot'): void;
|
|
185
|
-
protected propagateToOwningSide(item: T, method: 'add' | 'remove' | 'takeSnapshot'): void;
|
|
185
|
+
protected propagateToOwningSide(item: T, method: 'add' | 'remove' | 'takeSnapshot', hydration?: boolean): void;
|
|
186
186
|
protected shouldPropagateToCollection(collection: Collection<O, T>, method: 'add' | 'remove' | 'takeSnapshot'): boolean;
|
|
187
187
|
protected incrementCount(value: number): void;
|
|
188
188
|
}
|
package/entity/Collection.js
CHANGED
|
@@ -3,6 +3,7 @@ import { MetadataError, ValidationError } from '../errors.js';
|
|
|
3
3
|
import { DataloaderType, ReferenceKind } from '../enums.js';
|
|
4
4
|
import { Reference } from './Reference.js';
|
|
5
5
|
import { helper, wrap } from './wrap.js';
|
|
6
|
+
import { EntityHelper } from './EntityHelper.js';
|
|
6
7
|
import { QueryHelper } from '../utils/QueryHelper.js';
|
|
7
8
|
import { inspect } from '../logging/inspect.js';
|
|
8
9
|
// Globally registered so the marker survives the CJS/ESM dual-package hazard
|
|
@@ -167,7 +168,7 @@ export class Collection {
|
|
|
167
168
|
this.cancelOrphanRemoval(unwrapped);
|
|
168
169
|
return added;
|
|
169
170
|
}
|
|
170
|
-
addItems(items) {
|
|
171
|
+
addItems(items, hydration) {
|
|
171
172
|
this.validateModification(items);
|
|
172
173
|
let added = 0;
|
|
173
174
|
for (const entity of items) {
|
|
@@ -177,7 +178,7 @@ export class Collection {
|
|
|
177
178
|
this.#items.add(entity);
|
|
178
179
|
added++;
|
|
179
180
|
this.#dirty = true;
|
|
180
|
-
this.propagate(entity, 'add');
|
|
181
|
+
this.propagate(entity, 'add', hydration);
|
|
181
182
|
}
|
|
182
183
|
}
|
|
183
184
|
return added;
|
|
@@ -486,7 +487,7 @@ export class Collection {
|
|
|
486
487
|
/**
|
|
487
488
|
* @internal
|
|
488
489
|
*/
|
|
489
|
-
hydrate(items, forcePropagate, partial, readonly, count = true) {
|
|
490
|
+
hydrate(items, forcePropagate, partial, readonly, count = true, hydration) {
|
|
490
491
|
for (let i = 0; i < this.#items.size; i++) {
|
|
491
492
|
delete this[i];
|
|
492
493
|
}
|
|
@@ -496,7 +497,7 @@ export class Collection {
|
|
|
496
497
|
this.#count = count ? 0 : undefined;
|
|
497
498
|
// loaded items are not persisted, that would queue an auto-flush of their type on a read-only path
|
|
498
499
|
const unwrapped = items.map(i => Reference.unwrapReference(i));
|
|
499
|
-
this.addItems(unwrapped);
|
|
500
|
+
this.addItems(unwrapped, hydration);
|
|
500
501
|
this.cancelOrphanRemoval(unwrapped);
|
|
501
502
|
this.takeSnapshot(forcePropagate);
|
|
502
503
|
if (readonly) {
|
|
@@ -700,12 +701,12 @@ export class Collection {
|
|
|
700
701
|
// cannot be typed to `EntityProperty<O, T>` as it causes issues in assignability of `Loaded` type
|
|
701
702
|
this.#property = prop;
|
|
702
703
|
}
|
|
703
|
-
propagate(item, method) {
|
|
704
|
+
propagate(item, method, hydration) {
|
|
704
705
|
if (this.property.owner && this.property.inversedBy) {
|
|
705
706
|
this.propagateToInverseSide(item, method);
|
|
706
707
|
}
|
|
707
708
|
else if (!this.property.owner && this.property.mappedBy) {
|
|
708
|
-
this.propagateToOwningSide(item, method);
|
|
709
|
+
this.propagateToOwningSide(item, method, hydration);
|
|
709
710
|
}
|
|
710
711
|
}
|
|
711
712
|
propagateToInverseSide(item, method) {
|
|
@@ -715,7 +716,7 @@ export class Collection {
|
|
|
715
716
|
collection[method](this.owner);
|
|
716
717
|
}
|
|
717
718
|
}
|
|
718
|
-
propagateToOwningSide(item, method) {
|
|
719
|
+
propagateToOwningSide(item, method, hydration) {
|
|
719
720
|
const mappedBy = this.property.mappedBy;
|
|
720
721
|
const collection = item[mappedBy];
|
|
721
722
|
if (this.property.kind === ReferenceKind.MANY_TO_MANY) {
|
|
@@ -740,6 +741,10 @@ export class Collection {
|
|
|
740
741
|
// skip if already propagated
|
|
741
742
|
if (Reference.unwrapReference(item[mappedBy]) !== value) {
|
|
742
743
|
item[mappedBy] = value;
|
|
744
|
+
// propagation of a loaded relation is not a change, the FK goes straight to the snapshot
|
|
745
|
+
if (hydration && !prop2.mapToPk) {
|
|
746
|
+
EntityHelper.syncSnapshot(item, prop2, this.owner);
|
|
747
|
+
}
|
|
743
748
|
}
|
|
744
749
|
}
|
|
745
750
|
}
|
package/entity/EntityHelper.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EntityManager } from '../EntityManager.js';
|
|
2
|
-
import { type AnyEntity, type EntityMetadata, type EntityProperty
|
|
2
|
+
import { type AnyEntity, type EntityMetadata, type EntityProperty } from '../typings.js';
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
@@ -23,7 +23,12 @@ export declare class EntityHelper {
|
|
|
23
23
|
*/
|
|
24
24
|
private static defineProperties;
|
|
25
25
|
static defineCustomInspect<T extends object>(meta: EntityMetadata<T>): void;
|
|
26
|
-
static defineReferenceProperty<T extends object>(meta: EntityMetadata<T>, prop: EntityProperty<T>, ref: T
|
|
26
|
+
static defineReferenceProperty<T extends object>(meta: EntityMetadata<T>, prop: EntityProperty<T>, ref: T): void;
|
|
27
|
+
/**
|
|
28
|
+
* Stores the FK of a relation set during hydration in the snapshot of its owning side, so it is not seen as a change.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
static syncSnapshot(owner: AnyEntity, prop: EntityProperty<any>, target: AnyEntity): void;
|
|
27
32
|
/**
|
|
28
33
|
* Returns the database value of the FK pointing to the given entity.
|
|
29
34
|
* @internal
|
package/entity/EntityHelper.js
CHANGED
|
@@ -86,7 +86,7 @@ export class EntityHelper {
|
|
|
86
86
|
__helper: {
|
|
87
87
|
get() {
|
|
88
88
|
Object.defineProperty(this, '__helper', {
|
|
89
|
-
value: new WrappedEntity(this,
|
|
89
|
+
value: new WrappedEntity(this, ...helperParams),
|
|
90
90
|
enumerable: false,
|
|
91
91
|
configurable: true,
|
|
92
92
|
});
|
|
@@ -112,7 +112,7 @@ export class EntityHelper {
|
|
|
112
112
|
if (isReference) {
|
|
113
113
|
Object.defineProperty(meta.prototype, prop.name, {
|
|
114
114
|
set(val) {
|
|
115
|
-
EntityHelper.defineReferenceProperty(meta, prop, this
|
|
115
|
+
EntityHelper.defineReferenceProperty(meta, prop, this);
|
|
116
116
|
this[prop.name] = val;
|
|
117
117
|
},
|
|
118
118
|
configurable: true,
|
|
@@ -182,7 +182,7 @@ export class EntityHelper {
|
|
|
182
182
|
return ret === '[Object]' ? `[${name}]` : name + ' ' + ret;
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
-
static defineReferenceProperty(meta, prop, ref
|
|
185
|
+
static defineReferenceProperty(meta, prop, ref) {
|
|
186
186
|
const wrapped = helper(ref);
|
|
187
187
|
Object.defineProperty(ref, prop.name, {
|
|
188
188
|
get() {
|
|
@@ -196,16 +196,23 @@ export class EntityHelper {
|
|
|
196
196
|
old[prop.inversedBy].removeWithoutPropagation(this);
|
|
197
197
|
}
|
|
198
198
|
wrapped.__data[prop.name] = Reference.wrapReference(val, prop);
|
|
199
|
-
// when propagation from inside hydration, we set the FK to the entity data immediately
|
|
200
|
-
if (val && hydrator.isRunning() && wrapped.__originalEntityData && prop.owner) {
|
|
201
|
-
wrapped.__originalEntityData[prop.name] = EntityHelper.getForeignKeyValue(entity, prop, prop.targetMeta);
|
|
202
|
-
}
|
|
203
199
|
EntityHelper.propagate(meta, entity, this, prop, Reference.unwrapReference(val), old);
|
|
204
200
|
},
|
|
205
201
|
enumerable: true,
|
|
206
202
|
configurable: true,
|
|
207
203
|
});
|
|
208
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Stores the FK of a relation set during hydration in the snapshot of its owning side, so it is not seen as a change.
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
static syncSnapshot(owner, prop, target) {
|
|
210
|
+
const snapshot = helper(owner).__originalEntityData;
|
|
211
|
+
const targetMeta = prop.targetMeta ?? helper(target)?.__meta;
|
|
212
|
+
if (snapshot && targetMeta) {
|
|
213
|
+
snapshot[prop.name] = EntityHelper.getForeignKeyValue(target, prop, targetMeta);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
209
216
|
/**
|
|
210
217
|
* Returns the database value of the FK pointing to the given entity.
|
|
211
218
|
* @internal
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PopulatePath } from '../enums.js';
|
|
2
2
|
import type { EntityManager } from '../EntityManager.js';
|
|
3
|
-
import type { Dictionary, EntityData, EntityDictionary, EntityMetadata,
|
|
3
|
+
import type { Dictionary, EntityData, EntityDictionary, EntityMetadata, EntityKey, PopulateOptions, Primary, AutoPath, Ref, AddEager, LoadedReference, EntityDTO, Loaded, ExtractFieldsHint, ResolveSerializeFields, SerializeDTO, SerializeFieldsKeepPK, FromEntityType, IsSubset, MergeSelected } from '../typings.js';
|
|
4
4
|
import { Reference } from './Reference.js';
|
|
5
5
|
import { type AssignOptions } from './EntityAssigner.js';
|
|
6
6
|
import type { EntityLoaderOptions } from './EntityLoader.js';
|
|
@@ -36,11 +36,10 @@ export declare class WrappedEntity<Entity extends object> {
|
|
|
36
36
|
/** holds wrapped primary key, so we can compute change set without eager commit */
|
|
37
37
|
__identifier?: EntityIdentifier;
|
|
38
38
|
private readonly entity;
|
|
39
|
-
private readonly hydrator;
|
|
40
39
|
private readonly pkGetter?;
|
|
41
40
|
private readonly pkSerializer?;
|
|
42
41
|
private readonly pkGetterConverted?;
|
|
43
|
-
constructor(entity: Entity,
|
|
42
|
+
constructor(entity: Entity, pkGetter?: (e: Entity) => Primary<Entity>, pkSerializer?: (e: Entity) => string, pkGetterConverted?: (e: Entity) => Primary<Entity>);
|
|
44
43
|
/** Returns whether the entity has been fully loaded from the database. */
|
|
45
44
|
isInitialized(): boolean;
|
|
46
45
|
/** Returns whether the entity is managed by an EntityManager (tracked in the identity map). */
|
package/entity/WrappedEntity.js
CHANGED
|
@@ -8,9 +8,8 @@ import { EntitySerializer } from '../serialization/EntitySerializer.js';
|
|
|
8
8
|
import { expandDotPaths } from './utils.js';
|
|
9
9
|
/** @internal Wrapper attached to every managed entity, holding ORM state such as initialization flags, identity map references, and change tracking snapshots. */
|
|
10
10
|
export class WrappedEntity {
|
|
11
|
-
constructor(entity,
|
|
11
|
+
constructor(entity, pkGetter, pkSerializer, pkGetterConverted) {
|
|
12
12
|
this.entity = entity;
|
|
13
|
-
this.hydrator = hydrator;
|
|
14
13
|
this.pkGetter = pkGetter;
|
|
15
14
|
this.pkSerializer = pkSerializer;
|
|
16
15
|
this.pkGetterConverted = pkGetterConverted;
|
package/hydration/Hydrator.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export declare abstract class Hydrator implements IHydrator {
|
|
|
8
8
|
protected readonly metadata: MetadataStorage;
|
|
9
9
|
protected readonly platform: Platform;
|
|
10
10
|
protected readonly config: Configuration;
|
|
11
|
-
protected running: boolean;
|
|
12
11
|
constructor(metadata: MetadataStorage, platform: Platform, config: Configuration);
|
|
13
12
|
/**
|
|
14
13
|
* @inheritDoc
|
|
@@ -18,8 +17,6 @@ export declare abstract class Hydrator implements IHydrator {
|
|
|
18
17
|
* @inheritDoc
|
|
19
18
|
*/
|
|
20
19
|
hydrateReference<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, convertCustomTypes?: boolean, schema?: string, parentSchema?: string): void;
|
|
21
|
-
/** Returns whether the hydrator is currently in the middle of hydrating an entity. */
|
|
22
|
-
isRunning(): boolean;
|
|
23
20
|
protected getProperties<T extends object>(meta: EntityMetadata<T>, type: 'full' | 'reference'): EntityProperty<T>[];
|
|
24
21
|
protected hydrateProperty<T extends object>(entity: T, prop: EntityProperty<T>, data: EntityData<T>, factory: EntityFactory, newEntity?: boolean, convertCustomTypes?: boolean): void;
|
|
25
22
|
}
|
package/hydration/Hydrator.js
CHANGED
|
@@ -4,7 +4,6 @@ export class Hydrator {
|
|
|
4
4
|
metadata;
|
|
5
5
|
platform;
|
|
6
6
|
config;
|
|
7
|
-
running = false;
|
|
8
7
|
constructor(metadata, platform, config) {
|
|
9
8
|
this.metadata = metadata;
|
|
10
9
|
this.platform = platform;
|
|
@@ -14,28 +13,18 @@ export class Hydrator {
|
|
|
14
13
|
* @inheritDoc
|
|
15
14
|
*/
|
|
16
15
|
hydrate(entity, meta, data, factory, type, newEntity = false, convertCustomTypes = false, schema, parentSchema) {
|
|
17
|
-
// the running state is used to consider propagation as hydration, saving the values directly to the entity data,
|
|
18
|
-
// but we don't want that for new entities, their propagation should result in entity updates when flushing
|
|
19
|
-
this.running = !newEntity;
|
|
20
16
|
const props = this.getProperties(meta, type);
|
|
21
17
|
for (const prop of props) {
|
|
22
18
|
this.hydrateProperty(entity, prop, data, factory, newEntity, convertCustomTypes);
|
|
23
19
|
}
|
|
24
|
-
this.running = false;
|
|
25
20
|
}
|
|
26
21
|
/**
|
|
27
22
|
* @inheritDoc
|
|
28
23
|
*/
|
|
29
24
|
hydrateReference(entity, meta, data, factory, convertCustomTypes, schema, parentSchema) {
|
|
30
|
-
this.running = true;
|
|
31
25
|
meta.primaryKeys.forEach(pk => {
|
|
32
26
|
this.hydrateProperty(entity, meta.properties[pk], data, factory, false, convertCustomTypes);
|
|
33
27
|
});
|
|
34
|
-
this.running = false;
|
|
35
|
-
}
|
|
36
|
-
/** Returns whether the hydrator is currently in the middle of hydrating an entity. */
|
|
37
|
-
isRunning() {
|
|
38
|
-
return this.running;
|
|
39
28
|
}
|
|
40
29
|
getProperties(meta, type) {
|
|
41
30
|
if (type === 'reference') {
|
|
@@ -23,22 +23,14 @@ export class ObjectHydrator extends Hydrator {
|
|
|
23
23
|
*/
|
|
24
24
|
hydrate(entity, meta, data, factory, type, newEntity = false, convertCustomTypes = false, schema, parentSchema, normalizeAccessors) {
|
|
25
25
|
const hydrate = this.getEntityHydrator(meta, type, normalizeAccessors);
|
|
26
|
-
const running = this.running;
|
|
27
|
-
// the running state is used to consider propagation as hydration, saving the values directly to the entity data,
|
|
28
|
-
// but we don't want that for new entities, their propagation should result in entity updates when flushing
|
|
29
|
-
this.running = !newEntity;
|
|
30
26
|
Utils.callCompiledFunction(hydrate, entity, data, factory, newEntity, convertCustomTypes, schema, parentSchema, normalizeAccessors);
|
|
31
|
-
this.running = running;
|
|
32
27
|
}
|
|
33
28
|
/**
|
|
34
29
|
* @inheritDoc
|
|
35
30
|
*/
|
|
36
31
|
hydrateReference(entity, meta, data, factory, convertCustomTypes = false, schema, parentSchema, normalizeAccessors) {
|
|
37
32
|
const hydrate = this.getEntityHydrator(meta, 'reference', normalizeAccessors);
|
|
38
|
-
const running = this.running;
|
|
39
|
-
this.running = true;
|
|
40
33
|
Utils.callCompiledFunction(hydrate, entity, data, factory, false, convertCustomTypes, schema, parentSchema, normalizeAccessors);
|
|
41
|
-
this.running = running;
|
|
42
34
|
}
|
|
43
35
|
/**
|
|
44
36
|
* @internal Highly performance-sensitive method.
|
|
@@ -210,6 +202,25 @@ export class ObjectHydrator extends Hydrator {
|
|
|
210
202
|
ret.push(` }`);
|
|
211
203
|
}
|
|
212
204
|
}
|
|
205
|
+
// propagation of a loaded relation is not a change, the FK goes straight to the snapshot of the owning side
|
|
206
|
+
const prop2 = prop.targetMeta?.properties[prop.mappedBy];
|
|
207
|
+
const owner = prop.owner ? prop : prop2;
|
|
208
|
+
if ((prop.inversedBy || prop.mappedBy) && !prop.mapToPk && owner?.owner && !owner.mapToPk) {
|
|
209
|
+
const ownerKey = this.safeKey(`prop_${owner.name}_${this.#tmpIndex++}`);
|
|
210
|
+
context.set(ownerKey, owner);
|
|
211
|
+
context.set('syncSnapshot', EntityHelper.syncSnapshot);
|
|
212
|
+
ret.push(` if (!newEntity && data${dataKey} != null && entity${entityKey}) {`);
|
|
213
|
+
if (prop.owner) {
|
|
214
|
+
ret.push(` syncSnapshot(entity, ${ownerKey}, Reference.unwrapReference(entity${entityKey}));`);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
ret.push(` const target = Reference.unwrapReference(entity${entityKey});`);
|
|
218
|
+
ret.push(` if (Reference.unwrapReference(target${this.wrap(owner.name)}) === entity) {`);
|
|
219
|
+
ret.push(` syncSnapshot(target, ${ownerKey}, entity);`);
|
|
220
|
+
ret.push(` }`);
|
|
221
|
+
}
|
|
222
|
+
ret.push(` }`);
|
|
223
|
+
}
|
|
213
224
|
if (prop.customType?.ensureComparable(meta, prop)) {
|
|
214
225
|
registerCustomType(prop, this.safeKey(prop.name), 'convertToDatabaseValue', context);
|
|
215
226
|
ret.push(` if (data${dataKey} != null && typeof data${dataKey} !== 'object' && convertCustomTypes) {`);
|
|
@@ -230,7 +241,7 @@ export class ObjectHydrator extends Hydrator {
|
|
|
230
241
|
ret.push(` Collection.create(entity, ${this.quote(prop.name)}, items, true).setDirty();`);
|
|
231
242
|
ret.push(` } else {`);
|
|
232
243
|
// loaded items go through `hydrate()`, as `set()` would persist them and queue an auto-flush; the count stays unset, joined results can be filtered
|
|
233
|
-
ret.push(` Collection.create(entity, ${this.quote(prop.name)}, undefined, false).hydrate(items, true, false, false, false);`);
|
|
244
|
+
ret.push(` Collection.create(entity, ${this.quote(prop.name)}, undefined, false).hydrate(items, true, false, false, false, true);`);
|
|
234
245
|
ret.push(` }`);
|
|
235
246
|
ret.push(` } else if (!entity${entityKey} && data${dataKey} instanceof Collection) {`);
|
|
236
247
|
ret.push(` entity${entityKey} = data${dataKey};`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.2.12-dev.
|
|
3
|
+
"version": "7.2.12-dev.18",
|
|
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/typings.d.ts
CHANGED
|
@@ -426,7 +426,6 @@ export interface IWrappedEntityInternal<Entity extends object> extends IWrappedE
|
|
|
426
426
|
__platform: Platform;
|
|
427
427
|
__config: Configuration;
|
|
428
428
|
__factory: EntityFactory;
|
|
429
|
-
__hydrator: IHydrator;
|
|
430
429
|
__initialized: boolean;
|
|
431
430
|
__originalEntityData?: EntityData<Entity>;
|
|
432
431
|
__loadedProperties: Set<string>;
|
|
@@ -1753,7 +1752,6 @@ export interface IHydrator {
|
|
|
1753
1752
|
* Hydrates primary keys only
|
|
1754
1753
|
*/
|
|
1755
1754
|
hydrateReference<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, convertCustomTypes?: boolean, schema?: string, parentSchema?: string, normalizeAccessors?: boolean): void;
|
|
1756
|
-
isRunning(): boolean;
|
|
1757
1755
|
}
|
|
1758
1756
|
/** Constructor signature for hydrator implementations. */
|
|
1759
1757
|
export interface HydratorConstructor {
|
package/typings.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ReferenceKind, } from './enums.js';
|
|
2
2
|
import { Reference } from './entity/Reference.js';
|
|
3
3
|
import { EntityHelper } from './entity/EntityHelper.js';
|
|
4
|
-
import { helper } from './entity/wrap.js';
|
|
5
4
|
import { Utils } from './utils/Utils.js';
|
|
6
5
|
import { EntityComparator } from './utils/EntityComparator.js';
|
|
7
6
|
/** Symbol used to declare a custom repository type on an entity class (e.g., `[EntityRepositoryType]?: BookRepository`). */
|
|
@@ -279,7 +278,6 @@ export class EntityMetadata {
|
|
|
279
278
|
},
|
|
280
279
|
set(val) {
|
|
281
280
|
const wrapped = this.__helper;
|
|
282
|
-
const hydrator = wrapped.hydrator;
|
|
283
281
|
const entity = Reference.unwrapReference(val ?? wrapped.__data[prop.name]);
|
|
284
282
|
const old = Reference.unwrapReference(wrapped.__data[prop.name]);
|
|
285
283
|
if (old &&
|
|
@@ -290,13 +288,6 @@ export class EntityMetadata {
|
|
|
290
288
|
old[prop.inversedBy].removeWithoutPropagation(this);
|
|
291
289
|
}
|
|
292
290
|
wrapped.__data[prop.name] = Reference.wrapReference(val, prop);
|
|
293
|
-
// when propagation from inside hydration, we set the FK to the entity data immediately
|
|
294
|
-
if (val && hydrator.isRunning() && wrapped.__originalEntityData && prop.owner) {
|
|
295
|
-
const targetMeta = prop.targetMeta ?? helper(entity)?.__meta;
|
|
296
|
-
if (targetMeta) {
|
|
297
|
-
wrapped.__originalEntityData[prop.name] = EntityHelper.getForeignKeyValue(entity, prop, targetMeta);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
291
|
EntityHelper.propagate(meta, entity, this, prop, Reference.unwrapReference(val), old);
|
|
301
292
|
},
|
|
302
293
|
enumerable: true,
|
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.12-dev.
|
|
156
|
+
static #ORM_VERSION = '7.2.12-dev.18';
|
|
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}`;
|