@mikro-orm/core 6.3.14-dev.71 → 6.3.14-dev.72
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/errors.d.ts +1 -0
- package/errors.js +3 -0
- package/metadata/MetadataValidator.js +5 -2
- package/package.json +2 -2
- package/utils/Configuration.d.ts +4 -2
- package/utils/Configuration.js +2 -1
package/errors.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export declare class MetadataError<T extends AnyEntity = AnyEntity> extends Vali
|
|
|
55
55
|
static invalidPrimaryKey(meta: EntityMetadata, prop: EntityProperty, requiredName: string): MetadataError<Partial<any>>;
|
|
56
56
|
static invalidManyToManyWithPivotEntity(meta1: EntityMetadata, prop1: EntityProperty, meta2: EntityMetadata, prop2: EntityProperty): MetadataError<Partial<any>>;
|
|
57
57
|
static targetIsAbstract(meta: EntityMetadata, prop: EntityProperty): MetadataError<Partial<any>>;
|
|
58
|
+
static nonPersistentCompositeProp(meta: EntityMetadata, prop: EntityProperty): MetadataError<Partial<any>>;
|
|
58
59
|
static propertyTargetsEntityType(meta: EntityMetadata, prop: EntityProperty, target: EntityMetadata): MetadataError<Partial<any>>;
|
|
59
60
|
static fromMissingOption(meta: EntityMetadata, prop: EntityProperty, option: string): MetadataError<Partial<any>>;
|
|
60
61
|
private static fromMessage;
|
package/errors.js
CHANGED
|
@@ -198,6 +198,9 @@ class MetadataError extends ValidationError {
|
|
|
198
198
|
static targetIsAbstract(meta, prop) {
|
|
199
199
|
return this.fromMessage(meta, prop, `targets abstract entity ${prop.type}. Maybe you forgot to put @Entity() decorator on the ${prop.type} class?`);
|
|
200
200
|
}
|
|
201
|
+
static nonPersistentCompositeProp(meta, prop) {
|
|
202
|
+
return this.fromMessage(meta, prop, `is non-persistent relation which targets composite primary key. This is not supported and will cause issues, 'persist: false' should be added to the properties representing single columns instead.`);
|
|
203
|
+
}
|
|
201
204
|
static propertyTargetsEntityType(meta, prop, target) {
|
|
202
205
|
/* istanbul ignore next */
|
|
203
206
|
const suggestion = target.embeddable ? 'Embedded' : 'ManyToOne';
|
|
@@ -41,7 +41,7 @@ class MetadataValidator {
|
|
|
41
41
|
this.validateIndexes(meta, meta.uniques ?? [], 'unique');
|
|
42
42
|
for (const prop of utils_1.Utils.values(meta.properties)) {
|
|
43
43
|
if (prop.kind !== enums_1.ReferenceKind.SCALAR) {
|
|
44
|
-
this.validateReference(meta, prop, metadata);
|
|
44
|
+
this.validateReference(meta, prop, metadata, options);
|
|
45
45
|
this.validateBidirectional(meta, prop, metadata);
|
|
46
46
|
}
|
|
47
47
|
else if (metadata.has(prop.type)) {
|
|
@@ -98,7 +98,7 @@ class MetadataValidator {
|
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
validateReference(meta, prop, metadata) {
|
|
101
|
+
validateReference(meta, prop, metadata, options) {
|
|
102
102
|
// references do have types
|
|
103
103
|
if (!prop.type) {
|
|
104
104
|
throw errors_1.MetadataError.fromWrongTypeDefinition(meta, prop);
|
|
@@ -110,6 +110,9 @@ class MetadataValidator {
|
|
|
110
110
|
if (metadata.find(prop.type).abstract && !metadata.find(prop.type).discriminatorColumn) {
|
|
111
111
|
throw errors_1.MetadataError.targetIsAbstract(meta, prop);
|
|
112
112
|
}
|
|
113
|
+
if (prop.persist === false && metadata.find(prop.type).compositePK && options.checkNonPersistentCompositeProps) {
|
|
114
|
+
throw errors_1.MetadataError.nonPersistentCompositeProp(meta, prop);
|
|
115
|
+
}
|
|
113
116
|
}
|
|
114
117
|
validateBidirectional(meta, prop, metadata) {
|
|
115
118
|
if (prop.inversedBy) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.3.14-dev.
|
|
3
|
+
"version": "6.3.14-dev.72",
|
|
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.2.0",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.3.14-dev.
|
|
67
|
+
"mikro-orm": "6.3.14-dev.72",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/utils/Configuration.d.ts
CHANGED
|
@@ -34,9 +34,10 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
|
|
|
34
34
|
requireEntitiesArray: false;
|
|
35
35
|
checkDuplicateTableNames: true;
|
|
36
36
|
checkDuplicateFieldNames: true;
|
|
37
|
+
checkDuplicateEntities: true;
|
|
38
|
+
checkNonPersistentCompositeProps: true;
|
|
37
39
|
alwaysAnalyseProperties: true;
|
|
38
40
|
disableDynamicFileAccess: false;
|
|
39
|
-
checkDuplicateEntities: true;
|
|
40
41
|
inferDefaultValues: true;
|
|
41
42
|
};
|
|
42
43
|
strict: false;
|
|
@@ -294,11 +295,12 @@ export interface MetadataDiscoveryOptions {
|
|
|
294
295
|
requireEntitiesArray?: boolean;
|
|
295
296
|
checkDuplicateTableNames?: boolean;
|
|
296
297
|
checkDuplicateFieldNames?: boolean;
|
|
298
|
+
checkDuplicateEntities?: boolean;
|
|
299
|
+
checkNonPersistentCompositeProps?: boolean;
|
|
297
300
|
alwaysAnalyseProperties?: boolean;
|
|
298
301
|
disableDynamicFileAccess?: boolean;
|
|
299
302
|
inferDefaultValues?: boolean;
|
|
300
303
|
getMappedType?: (type: string, platform: Platform) => Type<unknown> | undefined;
|
|
301
|
-
checkDuplicateEntities?: boolean;
|
|
302
304
|
onMetadata?: (meta: EntityMetadata, platform: Platform) => MaybePromise<void>;
|
|
303
305
|
afterDiscovered?: (storage: MetadataStorage, platform: Platform) => MaybePromise<void>;
|
|
304
306
|
tsConfigPath?: string;
|
package/utils/Configuration.js
CHANGED
|
@@ -27,9 +27,10 @@ class Configuration {
|
|
|
27
27
|
requireEntitiesArray: false,
|
|
28
28
|
checkDuplicateTableNames: true,
|
|
29
29
|
checkDuplicateFieldNames: true,
|
|
30
|
+
checkDuplicateEntities: true,
|
|
31
|
+
checkNonPersistentCompositeProps: true,
|
|
30
32
|
alwaysAnalyseProperties: true,
|
|
31
33
|
disableDynamicFileAccess: false,
|
|
32
|
-
checkDuplicateEntities: true,
|
|
33
34
|
inferDefaultValues: true,
|
|
34
35
|
},
|
|
35
36
|
strict: false,
|