@mikro-orm/core 7.1.8-dev.4 → 7.1.8-dev.6
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
|
@@ -1432,7 +1432,7 @@ export class EntityManager {
|
|
|
1432
1432
|
options.validate ??= true;
|
|
1433
1433
|
options.cascade ??= true;
|
|
1434
1434
|
validatePrimaryKey(data, em.metadata.get(entityName));
|
|
1435
|
-
let entity = em.#unitOfWork.tryGetById(entityName, data, options.schema, false);
|
|
1435
|
+
let entity = em.#unitOfWork.tryGetById(entityName, data, options.schema, false, options.convertCustomTypes);
|
|
1436
1436
|
if (entity && helper(entity).__managed && helper(entity).__initialized && !options.refresh) {
|
|
1437
1437
|
return entity;
|
|
1438
1438
|
}
|
package/entity/EntityAssigner.js
CHANGED
|
@@ -187,7 +187,9 @@ export class EntityAssigner {
|
|
|
187
187
|
if (options.updateNestedEntities && options.updateByPrimaryKey && Utils.isPlainObject(item)) {
|
|
188
188
|
const pk = Utils.extractPK(item, prop.targetMeta);
|
|
189
189
|
if (pk && EntityAssigner.validateEM(em)) {
|
|
190
|
-
const ref = em
|
|
190
|
+
const ref = em
|
|
191
|
+
.getUnitOfWork()
|
|
192
|
+
.getById(prop.targetMeta.class, pk, options.schema, options.convertCustomTypes);
|
|
191
193
|
if (ref) {
|
|
192
194
|
return EntityAssigner.assign(ref, item, options);
|
|
193
195
|
}
|
package/entity/EntityFactory.js
CHANGED
|
@@ -421,7 +421,7 @@ export class EntityFactory {
|
|
|
421
421
|
const value = data[k];
|
|
422
422
|
if (prop && [ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind) && value) {
|
|
423
423
|
const pk = Reference.unwrapReference(value);
|
|
424
|
-
const entity = this.unitOfWork.getById(prop.targetMeta.class, pk, options.schema,
|
|
424
|
+
const entity = this.unitOfWork.getById(prop.targetMeta.class, pk, options.schema, options.convertCustomTypes);
|
|
425
425
|
if (entity) {
|
|
426
426
|
return entity;
|
|
427
427
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.1.8-dev.
|
|
3
|
+
"version": "7.1.8-dev.6",
|
|
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",
|
|
@@ -48,7 +48,7 @@ export declare class UnitOfWork {
|
|
|
48
48
|
*/
|
|
49
49
|
storeByKey<T extends object>(entity: T, key: string, value: unknown, schema?: string, convertCustomTypes?: boolean): void;
|
|
50
50
|
/** Attempts to extract a primary key from the where condition and look up the entity in the identity map. */
|
|
51
|
-
tryGetById<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, schema?: string, strict?: boolean): T | null;
|
|
51
|
+
tryGetById<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, schema?: string, strict?: boolean, convertCustomTypes?: boolean): T | null;
|
|
52
52
|
/**
|
|
53
53
|
* Returns map of all managed entities.
|
|
54
54
|
*/
|
|
@@ -227,12 +227,12 @@ export class UnitOfWork {
|
|
|
227
227
|
this.#identityMap.storeByKey(entity, key, '' + value, schema);
|
|
228
228
|
}
|
|
229
229
|
/** Attempts to extract a primary key from the where condition and look up the entity in the identity map. */
|
|
230
|
-
tryGetById(entityName, where, schema, strict = true) {
|
|
230
|
+
tryGetById(entityName, where, schema, strict = true, convertCustomTypes) {
|
|
231
231
|
const pk = Utils.extractPK(where, this.#metadata.find(entityName), strict);
|
|
232
232
|
if (!pk) {
|
|
233
233
|
return null;
|
|
234
234
|
}
|
|
235
|
-
return this.getById(entityName, pk, schema);
|
|
235
|
+
return this.getById(entityName, pk, schema, convertCustomTypes);
|
|
236
236
|
}
|
|
237
237
|
/**
|
|
238
238
|
* Returns map of all managed entities.
|
|
@@ -162,7 +162,8 @@ export class TransactionManager {
|
|
|
162
162
|
for (const entity of fork.getUnitOfWork(false).getIdentityMap()) {
|
|
163
163
|
const wrapped = helper(entity);
|
|
164
164
|
const meta = wrapped.__meta;
|
|
165
|
-
|
|
165
|
+
// the identity map is keyed by the database form, so the lookup has to use it too
|
|
166
|
+
const parentEntity = parentUoW.getById(meta.class, wrapped.getPrimaryKey(true), parent.schema, true);
|
|
166
167
|
if (parentEntity && parentEntity !== entity) {
|
|
167
168
|
const parentWrapped = helper(parentEntity);
|
|
168
169
|
// Don't overwrite a fully-loaded entity with an uninitialized reference
|
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.1.8-dev.
|
|
156
|
+
static #ORM_VERSION = '7.1.8-dev.6';
|
|
157
157
|
/**
|
|
158
158
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
159
159
|
*/
|