@mikro-orm/core 7.0.10-dev.4 → 7.0.10-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/entity/EntityHelper.js +16 -5
- package/metadata/MetadataDiscovery.js +1 -1
- package/package.json +1 -1
- package/utils/Utils.js +1 -1
- package/utils/fs-utils.js +5 -4
package/entity/EntityHelper.js
CHANGED
|
@@ -39,11 +39,6 @@ export class EntityHelper {
|
|
|
39
39
|
// toJSON can be overridden
|
|
40
40
|
Object.defineProperty(prototype, 'toJSON', {
|
|
41
41
|
value: function (...args) {
|
|
42
|
-
// Guard against being called on the prototype itself (e.g. by serializers
|
|
43
|
-
// walking the object graph and calling toJSON on prototype objects)
|
|
44
|
-
if (this === prototype) {
|
|
45
|
-
return {};
|
|
46
|
-
}
|
|
47
42
|
return EntityTransformer.toObject(this, ...args);
|
|
48
43
|
},
|
|
49
44
|
writable: true,
|
|
@@ -51,6 +46,22 @@ export class EntityHelper {
|
|
|
51
46
|
enumerable: false,
|
|
52
47
|
});
|
|
53
48
|
}
|
|
49
|
+
// Walkers / serializers reaching the prototype directly invoke its methods and
|
|
50
|
+
// accessors with `this === prototype`. Wrap each so that case is a no-op rather
|
|
51
|
+
// than throwing (when a user `@Property({ persist: false })` getter dereferences
|
|
52
|
+
// unhydrated instance state) or installing state on the prototype itself (#7151).
|
|
53
|
+
for (const name of Object.getOwnPropertyNames(prototype)) {
|
|
54
|
+
const desc = Object.getOwnPropertyDescriptor(prototype, name);
|
|
55
|
+
const fn = desc.get ?? desc.value;
|
|
56
|
+
if (name === 'constructor' || typeof fn !== 'function' || fn.__guarded) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const guarded = function (...args) {
|
|
60
|
+
return this === prototype ? undefined : fn.apply(this, args);
|
|
61
|
+
};
|
|
62
|
+
guarded.__guarded = true;
|
|
63
|
+
Object.defineProperty(prototype, name, desc.get ? { ...desc, get: guarded } : { ...desc, value: guarded });
|
|
64
|
+
}
|
|
54
65
|
}
|
|
55
66
|
/**
|
|
56
67
|
* As a performance optimization, we create entity state methods lazily. We first add
|
|
@@ -393,7 +393,7 @@ export class MetadataDiscovery {
|
|
|
393
393
|
}
|
|
394
394
|
if (prop.joinColumns.length > 1) {
|
|
395
395
|
prop.ownColumns = prop.joinColumns.filter(col => {
|
|
396
|
-
return !meta.props.find(p => p.name !== prop.name &&
|
|
396
|
+
return !meta.props.find(p => p.name !== prop.name && p.fieldNames?.includes(col));
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
399
|
if (!prop.ownColumns || prop.ownColumns.length === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.0.10-dev.
|
|
3
|
+
"version": "7.0.10-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",
|
package/utils/Utils.js
CHANGED
|
@@ -132,7 +132,7 @@ export function parseJsonSafe(value) {
|
|
|
132
132
|
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
133
133
|
export class Utils {
|
|
134
134
|
static PK_SEPARATOR = '~~~';
|
|
135
|
-
static #ORM_VERSION = '7.0.10-dev.
|
|
135
|
+
static #ORM_VERSION = '7.0.10-dev.6';
|
|
136
136
|
/**
|
|
137
137
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
138
138
|
*/
|
package/utils/fs-utils.js
CHANGED
|
@@ -14,10 +14,11 @@ export const fs = {
|
|
|
14
14
|
if (tinyGlobby) {
|
|
15
15
|
globSync = (patterns, options) => {
|
|
16
16
|
patterns = Utils.asArray(patterns).map(p => p.replace(/\\/g, '/'));
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
// never forward `cwd: undefined` — tinyglobby >= 0.2.16 calls `path.resolve(undefined)` and throws
|
|
18
|
+
return tinyGlobby.globSync(patterns, {
|
|
19
|
+
expandDirectories: false,
|
|
20
|
+
...(options?.cwd && { cwd: options.cwd.replace(/\\/g, '/') }),
|
|
21
|
+
});
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
},
|