@mikro-orm/core 6.4.4-dev.15 → 6.4.4-dev.16
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.
|
@@ -59,6 +59,7 @@ class EntityValidator {
|
|
|
59
59
|
return givenValue;
|
|
60
60
|
}
|
|
61
61
|
const expectedType = prop.runtimeType;
|
|
62
|
+
const propName = prop.embedded ? prop.name.replace(/~/g, '.') : prop.name;
|
|
62
63
|
let givenType = Utils_1.Utils.getObjectType(givenValue);
|
|
63
64
|
let ret = givenValue;
|
|
64
65
|
if (!this.strict) {
|
|
@@ -67,12 +68,12 @@ class EntityValidator {
|
|
|
67
68
|
}
|
|
68
69
|
if (prop.enum && prop.items) {
|
|
69
70
|
if (!prop.items.some(it => it === givenValue)) {
|
|
70
|
-
throw errors_1.ValidationError.fromWrongPropertyType(entity,
|
|
71
|
+
throw errors_1.ValidationError.fromWrongPropertyType(entity, propName, expectedType, givenType, givenValue);
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
else {
|
|
74
75
|
if (givenType !== expectedType && this.KNOWN_TYPES.has(expectedType)) {
|
|
75
|
-
throw errors_1.ValidationError.fromWrongPropertyType(entity,
|
|
76
|
+
throw errors_1.ValidationError.fromWrongPropertyType(entity, propName, expectedType, givenType, givenValue);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
return ret;
|
|
@@ -826,10 +826,11 @@ class MetadataDiscovery {
|
|
|
826
826
|
const parentProperty = meta.properties[embeddedProp.embedded?.[0] ?? ''];
|
|
827
827
|
const object = isParentObject(embeddedProp);
|
|
828
828
|
this.initFieldName(embeddedProp, rootProperty !== embeddedProp && object);
|
|
829
|
-
// the prefix of the parent
|
|
829
|
+
// the prefix of the parent cannot be a boolean; it already passed here
|
|
830
830
|
const prefix = this.getPrefix(embeddedProp, parentProperty);
|
|
831
|
+
const glue = object ? '~' : '_';
|
|
831
832
|
for (const prop of Object.values(embeddable.properties)) {
|
|
832
|
-
const name = (embeddedProp.embeddedPath?.join(
|
|
833
|
+
const name = (embeddedProp.embeddedPath?.join(glue) ?? embeddedProp.fieldNames[0] + glue) + prop.name;
|
|
833
834
|
meta.properties[name] = Utils_1.Utils.copy(prop, false);
|
|
834
835
|
meta.properties[name].name = name;
|
|
835
836
|
meta.properties[name].embedded = [embeddedProp.name, prop.name];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.4.4-dev.
|
|
3
|
+
"version": "6.4.4-dev.16",
|
|
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.4-dev.
|
|
67
|
+
"mikro-orm": "6.4.4-dev.16",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -389,8 +389,8 @@ class EntityComparator {
|
|
|
389
389
|
dataKey = dataKey.replace(/^\./, '');
|
|
390
390
|
const contains = (str, re) => (str.match(re) || []).length > 0;
|
|
391
391
|
const a = contains(dataKey, /\./g);
|
|
392
|
-
const b = contains(dataKey, /\[/g);
|
|
393
|
-
return !!prop.object && !
|
|
392
|
+
const b = contains(dataKey, /\[idx_/g);
|
|
393
|
+
return !!prop.object && !a && !b;
|
|
394
394
|
}
|
|
395
395
|
getEmbeddedPropertySnapshot(meta, prop, context, level, path, dataKey, object = prop.object) {
|
|
396
396
|
const padding = ' '.repeat(level * 2);
|