@mikro-orm/core 6.4.14-dev.0 → 6.4.14-dev.10

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
@@ -1261,7 +1261,7 @@ class EntityManager {
1261
1261
  delete options.orderBy;
1262
1262
  const cacheKey = em.cacheKey(entityName, options, 'em.count', where);
1263
1263
  const cached = await em.tryCache(entityName, options.cache, cacheKey);
1264
- if (cached?.data) {
1264
+ if (cached?.data !== undefined) {
1265
1265
  return cached.data;
1266
1266
  }
1267
1267
  const count = await em.driver.count(entityName, where, { ctx: em.transactionContext, ...options });
@@ -1685,34 +1685,31 @@ class EntityManager {
1685
1685
  const em = this.getContext();
1686
1686
  const cacheKey = Array.isArray(config) ? config[0] : JSON.stringify(key);
1687
1687
  const cached = await em.resultCache.get(cacheKey);
1688
- if (cached === null) {
1689
- return { key: cacheKey, data: null };
1690
- }
1691
- if (cached) {
1692
- let data;
1693
- if (Array.isArray(cached) && merge) {
1694
- data = cached.map(item => em.entityFactory.create(entityName, item, {
1695
- merge: true,
1696
- convertCustomTypes: true,
1697
- refresh,
1698
- recomputeSnapshot: true,
1699
- }));
1700
- }
1701
- else if (utils_1.Utils.isObject(cached) && merge) {
1702
- data = em.entityFactory.create(entityName, cached, {
1703
- merge: true,
1704
- convertCustomTypes: true,
1705
- refresh,
1706
- recomputeSnapshot: true,
1707
- });
1708
- }
1709
- else {
1710
- data = cached;
1711
- }
1712
- await em.unitOfWork.dispatchOnLoadEvent();
1713
- return { key: cacheKey, data };
1688
+ if (!cached) {
1689
+ return { key: cacheKey, data: cached };
1690
+ }
1691
+ let data;
1692
+ if (Array.isArray(cached) && merge) {
1693
+ data = cached.map(item => em.entityFactory.create(entityName, item, {
1694
+ merge: true,
1695
+ convertCustomTypes: true,
1696
+ refresh,
1697
+ recomputeSnapshot: true,
1698
+ }));
1714
1699
  }
1715
- return { key: cacheKey };
1700
+ else if (utils_1.Utils.isObject(cached) && merge) {
1701
+ data = em.entityFactory.create(entityName, cached, {
1702
+ merge: true,
1703
+ convertCustomTypes: true,
1704
+ refresh,
1705
+ recomputeSnapshot: true,
1706
+ });
1707
+ }
1708
+ else {
1709
+ data = cached;
1710
+ }
1711
+ await em.unitOfWork.dispatchOnLoadEvent();
1712
+ return { key: cacheKey, data };
1716
1713
  }
1717
1714
  /**
1718
1715
  * @internal
package/enums.d.ts CHANGED
@@ -66,7 +66,7 @@ export declare enum QueryOrderNumeric {
66
66
  ASC = 1,
67
67
  DESC = -1
68
68
  }
69
- export type QueryOrderKeysFlat = QueryOrder | QueryOrderNumeric | keyof typeof QueryOrder;
69
+ export type QueryOrderKeysFlat = QueryOrder | QueryOrderNumeric | `${QueryOrder}`;
70
70
  export type QueryOrderKeys<T> = QueryOrderKeysFlat | QueryOrderMap<T>;
71
71
  export type QueryOrderMap<T> = {
72
72
  [K in EntityKey<T>]?: QueryOrderKeys<ExpandProperty<T[K]>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.4.14-dev.0",
3
+ "version": "6.4.14-dev.10",
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.0",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.4.14-dev.0",
67
+ "mikro-orm": "6.4.14-dev.10",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -610,7 +610,7 @@ class EntityComparator {
610
610
  * perf: used to generate list of comparable properties during discovery, so we speed up the runtime comparison
611
611
  */
612
612
  static isComparable(prop, root) {
613
- const virtual = prop.persist === false || prop.generated;
613
+ const virtual = prop.persist === false || (prop.generated && !prop.primary);
614
614
  const inverse = prop.kind === enums_1.ReferenceKind.ONE_TO_ONE && !prop.owner;
615
615
  const discriminator = prop.name === root.discriminatorColumn;
616
616
  const collection = prop.kind === enums_1.ReferenceKind.ONE_TO_MANY || prop.kind === enums_1.ReferenceKind.MANY_TO_MANY;