@mikro-orm/core 6.3.14-dev.52 → 6.3.14-dev.54
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/decorators/ManyToOne.d.ts +2 -0
- package/drivers/DatabaseDriver.js +1 -1
- package/metadata/MetadataDiscovery.d.ts +1 -0
- package/metadata/MetadataDiscovery.js +17 -0
- package/package.json +2 -2
- package/typings.d.ts +1 -0
- package/utils/Configuration.d.ts +2 -0
- package/utils/Configuration.js +1 -0
|
@@ -15,6 +15,8 @@ export interface ManyToOneOptions<Owner, Target> extends ReferenceOptions<Owner,
|
|
|
15
15
|
joinColumn?: string;
|
|
16
16
|
/** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
|
|
17
17
|
joinColumns?: string[];
|
|
18
|
+
/** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */
|
|
19
|
+
ownColumns?: string[];
|
|
18
20
|
/** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
|
|
19
21
|
referenceColumnName?: string;
|
|
20
22
|
/** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
|
|
@@ -223,7 +223,7 @@ class DatabaseDriver {
|
|
|
223
223
|
}
|
|
224
224
|
if (prop.joinColumns?.length > 1 && data[k] == null) {
|
|
225
225
|
delete data[k];
|
|
226
|
-
prop.
|
|
226
|
+
prop.ownColumns.forEach(joinColumn => data[joinColumn] = null);
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
229
229
|
if (prop.customType && convertCustomTypes && !(prop.customType instanceof JsonType_1.JsonType && object) && !this.platform.isRaw(data[k])) {
|
|
@@ -361,6 +361,22 @@ class MetadataDiscovery {
|
|
|
361
361
|
this.initOneToManyFields(prop);
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
|
+
initOwnColumns(meta) {
|
|
365
|
+
meta.sync();
|
|
366
|
+
for (const prop of meta.props) {
|
|
367
|
+
if (!prop.joinColumns || prop.ownColumns) {
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
if (prop.joinColumns.length > 1) {
|
|
371
|
+
prop.ownColumns = prop.joinColumns.filter(col => {
|
|
372
|
+
return !meta.props.find(p => p.name !== prop.name && (!p.fieldNames || p.fieldNames.includes(col)));
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
if (!prop.ownColumns || prop.ownColumns.length === 0) {
|
|
376
|
+
prop.ownColumns = prop.joinColumns;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
364
380
|
initFieldName(prop, object = false) {
|
|
365
381
|
if (prop.fieldNames && prop.fieldNames.length > 0) {
|
|
366
382
|
return;
|
|
@@ -469,6 +485,7 @@ class MetadataDiscovery {
|
|
|
469
485
|
this.initColumnType(prop);
|
|
470
486
|
this.initRelation(prop);
|
|
471
487
|
}
|
|
488
|
+
this.initOwnColumns(meta);
|
|
472
489
|
meta.simplePK = pks.length === 1 && pks[0].kind === enums_1.ReferenceKind.SCALAR && !pks[0].customType && pks[0].runtimeType !== 'Date';
|
|
473
490
|
meta.serializedPrimaryKey = this.platform.getSerializedPrimaryKeyField(meta.primaryKeys[0]);
|
|
474
491
|
const serializedPKProp = meta.properties[meta.serializedPrimaryKey];
|
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.54",
|
|
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.54",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/typings.d.ts
CHANGED
|
@@ -365,6 +365,7 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
365
365
|
pivotTable: string;
|
|
366
366
|
pivotEntity: string;
|
|
367
367
|
joinColumns: string[];
|
|
368
|
+
ownColumns: string[];
|
|
368
369
|
inverseJoinColumns: string[];
|
|
369
370
|
referencedColumnNames: string[];
|
|
370
371
|
referencedTableName: string;
|
package/utils/Configuration.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
|
|
|
57
57
|
populateWhere: PopulateHint.ALL;
|
|
58
58
|
connect: true;
|
|
59
59
|
ignoreUndefinedInQuery: false;
|
|
60
|
+
onQuery: (sql: string) => string;
|
|
60
61
|
autoJoinOneToOneOwner: true;
|
|
61
62
|
autoJoinRefsForFilters: true;
|
|
62
63
|
propagationOnPrototype: true;
|
|
@@ -323,6 +324,7 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
|
|
|
323
324
|
connect: boolean;
|
|
324
325
|
verbose: boolean;
|
|
325
326
|
ignoreUndefinedInQuery?: boolean;
|
|
327
|
+
onQuery: (sql: string, params: unknown[]) => string;
|
|
326
328
|
autoJoinOneToOneOwner: boolean;
|
|
327
329
|
autoJoinRefsForFilters: boolean;
|
|
328
330
|
propagationOnPrototype: boolean;
|
package/utils/Configuration.js
CHANGED