@mikro-orm/core 7.2.8-dev.1 → 7.2.8-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.js +18 -1
- package/package.json +1 -1
- package/utils/Utils.js +1 -1
package/EntityManager.js
CHANGED
|
@@ -19,6 +19,23 @@ import { TransactionEventBroadcaster } from './events/TransactionEventBroadcaste
|
|
|
19
19
|
import { MetadataError, OptimisticLockError, ValidationError } from './errors.js';
|
|
20
20
|
import { applyPopulateHints, getLoadingStrategy } from './entity/utils.js';
|
|
21
21
|
import { TransactionManager } from './utils/TransactionManager.js';
|
|
22
|
+
// JSON loses RegExp patterns, `raw()` params and `raw()` keys (symbols); `this[key]` is the value before `toJSON()`
|
|
23
|
+
function cacheKeyReplacer(key, value) {
|
|
24
|
+
const original = this[key];
|
|
25
|
+
if (original instanceof RegExp) {
|
|
26
|
+
return { regexp: original.source, flags: original.flags };
|
|
27
|
+
}
|
|
28
|
+
if (isRaw(original)) {
|
|
29
|
+
return { sql: original.sql, params: original.params };
|
|
30
|
+
}
|
|
31
|
+
if (Raw.hasObjectFragments(value)) {
|
|
32
|
+
return Utils.getObjectQueryKeys(value).map(k => [
|
|
33
|
+
Raw.getKnownFragment(k) ?? k,
|
|
34
|
+
value[k],
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
22
39
|
/**
|
|
23
40
|
* The EntityManager is the central access point to ORM functionality. It is a facade to all different ORM subsystems
|
|
24
41
|
* such as UnitOfWork, Query Language, and Repository API.
|
|
@@ -2462,7 +2479,7 @@ export class EntityManager {
|
|
|
2462
2479
|
? em.#sessionContext
|
|
2463
2480
|
? `${config[0]}|${JSON.stringify(em.#sessionContext)}`
|
|
2464
2481
|
: config[0]
|
|
2465
|
-
: JSON.stringify(key);
|
|
2482
|
+
: JSON.stringify(key, cacheKeyReplacer);
|
|
2466
2483
|
const cached = await em.#resultCache.get(cacheKey);
|
|
2467
2484
|
if (!cached) {
|
|
2468
2485
|
return { key: cacheKey, data: cached };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.2.8-dev.
|
|
3
|
+
"version": "7.2.8-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
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
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.8-dev.
|
|
156
|
+
static #ORM_VERSION = '7.2.8-dev.2';
|
|
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}`;
|