@mikro-orm/entity-generator 7.1.0-dev.45 → 7.1.0-dev.47
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/SourceFile.d.ts +1 -0
- package/SourceFile.js +12 -9
- package/package.json +3 -3
package/SourceFile.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare class SourceFile {
|
|
|
30
30
|
protected serializeObject(options: {}, wordwrap?: number, spaces?: number, level?: number): string;
|
|
31
31
|
protected serializeValue(val: unknown, wordwrap?: number, spaces?: number, level?: number): unknown;
|
|
32
32
|
protected getEntityDeclOptions(): EntityOptions<unknown>;
|
|
33
|
+
private isDiscriminatorPropertyUserDefined;
|
|
33
34
|
protected getPartitionByDecl(partitionBy: EntityPartitionBy): Dictionary;
|
|
34
35
|
protected getEmbeddableDeclOptions(): EmbeddableOptions<unknown>;
|
|
35
36
|
private getCollectionDecl;
|
package/SourceFile.js
CHANGED
|
@@ -493,7 +493,15 @@ export class SourceFile {
|
|
|
493
493
|
if (this.meta.virtual) {
|
|
494
494
|
options.virtual = this.meta.virtual;
|
|
495
495
|
}
|
|
496
|
-
|
|
496
|
+
// when the discriminator references an explicitly defined property, emit the property-oriented
|
|
497
|
+
// `discriminator` name; fall back to `discriminatorColumn` when the discriminator property is
|
|
498
|
+
// auto-managed by the ORM and not part of the entity definition.
|
|
499
|
+
const key = this.isDiscriminatorPropertyUserDefined() ? 'discriminator' : 'discriminatorColumn';
|
|
500
|
+
return this.getCollectionDecl(options, key);
|
|
501
|
+
}
|
|
502
|
+
isDiscriminatorPropertyUserDefined() {
|
|
503
|
+
const name = this.meta.discriminatorColumn;
|
|
504
|
+
return !!name && this.meta.properties[name]?.userDefined !== false;
|
|
497
505
|
}
|
|
498
506
|
getPartitionByDecl(partitionBy) {
|
|
499
507
|
const result = { type: this.quote(partitionBy.type) };
|
|
@@ -531,14 +539,9 @@ export class SourceFile {
|
|
|
531
539
|
}
|
|
532
540
|
getEmbeddableDeclOptions() {
|
|
533
541
|
const options = {};
|
|
534
|
-
|
|
535
|
-
if (result.discriminatorColumn) {
|
|
536
|
-
result.discriminator = result.discriminatorColumn;
|
|
537
|
-
delete result.discriminatorColumn;
|
|
538
|
-
}
|
|
539
|
-
return result;
|
|
542
|
+
return this.getCollectionDecl(options, 'discriminator');
|
|
540
543
|
}
|
|
541
|
-
getCollectionDecl(options) {
|
|
544
|
+
getCollectionDecl(options, discriminatorKey) {
|
|
542
545
|
if (this.meta.abstract) {
|
|
543
546
|
options.abstract = true;
|
|
544
547
|
}
|
|
@@ -549,7 +552,7 @@ export class SourceFile {
|
|
|
549
552
|
: this.meta.discriminatorValue;
|
|
550
553
|
}
|
|
551
554
|
if (this.meta.discriminatorColumn) {
|
|
552
|
-
options
|
|
555
|
+
options[discriminatorKey] = this.quote(this.meta.discriminatorColumn);
|
|
553
556
|
}
|
|
554
557
|
if (this.meta.discriminatorMap) {
|
|
555
558
|
options.discriminatorMap = Object.fromEntries(Object.entries(this.meta.discriminatorMap).map(([discriminatorValue, cls]) => [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/entity-generator",
|
|
3
|
-
"version": "7.1.0-dev.
|
|
3
|
+
"version": "7.1.0-dev.47",
|
|
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",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@mikro-orm/sql": "7.1.0-dev.
|
|
50
|
+
"@mikro-orm/sql": "7.1.0-dev.47"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@mikro-orm/core": "^7.0.17"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.1.0-dev.
|
|
56
|
+
"@mikro-orm/core": "7.1.0-dev.47"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|