@mikro-orm/core 6.4.13 → 6.4.14-dev.1

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.
@@ -486,7 +486,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
486
486
  * @internal
487
487
  */
488
488
  tryCache<T extends object, R>(entityName: string, config: boolean | number | [string, number] | undefined, key: unknown, refresh?: boolean, merge?: boolean): Promise<{
489
- data?: R;
489
+ data?: R | null;
490
490
  key: string;
491
491
  } | undefined>;
492
492
  /**
package/EntityManager.js CHANGED
@@ -529,14 +529,16 @@ class EntityManager {
529
529
  options.populate = await em.preparePopulate(entityName, options);
530
530
  const cacheKey = em.cacheKey(entityName, options, 'em.findOne', where);
531
531
  const cached = await em.tryCache(entityName, options.cache, cacheKey, options.refresh, true);
532
- if (cached?.data) {
533
- await em.entityLoader.populate(entityName, [cached.data], options.populate, {
534
- ...options,
535
- ...em.getPopulateWhere(where, options),
536
- convertCustomTypes: false,
537
- ignoreLazyScalarProperties: true,
538
- lookup: false,
539
- });
532
+ if (cached?.data !== undefined) {
533
+ if (cached.data) {
534
+ await em.entityLoader.populate(entityName, [cached.data], options.populate, {
535
+ ...options,
536
+ ...em.getPopulateWhere(where, options),
537
+ convertCustomTypes: false,
538
+ ignoreLazyScalarProperties: true,
539
+ lookup: false,
540
+ });
541
+ }
540
542
  return cached.data;
541
543
  }
542
544
  options = { ...options };
@@ -1683,6 +1685,9 @@ class EntityManager {
1683
1685
  const em = this.getContext();
1684
1686
  const cacheKey = Array.isArray(config) ? config[0] : JSON.stringify(key);
1685
1687
  const cached = await em.resultCache.get(cacheKey);
1688
+ if (cached === null) {
1689
+ return { key: cacheKey, data: null };
1690
+ }
1686
1691
  if (cached) {
1687
1692
  let data;
1688
1693
  if (Array.isArray(cached) && merge) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.4.13",
3
+ "version": "6.4.14-dev.1",
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.13",
67
+ "mikro-orm": "6.4.14-dev.1",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }