@mikro-orm/core 7.0.13-dev.9 → 7.0.14-dev.0
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.
|
@@ -114,7 +114,12 @@ export class MetadataDiscovery {
|
|
|
114
114
|
}
|
|
115
115
|
else {
|
|
116
116
|
const name = prop.name;
|
|
117
|
-
|
|
117
|
+
// For to-one relations, only swap to the accessor for the documented
|
|
118
|
+
// backing-field convention (a `_`-prefixed property like `_draft` paired
|
|
119
|
+
// with `accessor: 'draft'`). The non-prefixed sibling-helper pattern
|
|
120
|
+
// (`author` + `accessor: 'authorId'`) keeps the property name as the
|
|
121
|
+
// canonical FK column source, so this stays non-breaking.
|
|
122
|
+
if (prop.kind === ReferenceKind.SCALAR || prop.kind === ReferenceKind.EMBEDDED || name.startsWith('_')) {
|
|
118
123
|
prop.name = prop.accessor;
|
|
119
124
|
}
|
|
120
125
|
this.initRelation(prop);
|
|
@@ -1191,7 +1196,10 @@ export class MetadataDiscovery {
|
|
|
1191
1196
|
if (!rootProp || rootProp.kind !== prop.kind) {
|
|
1192
1197
|
return false;
|
|
1193
1198
|
}
|
|
1194
|
-
if (prop.kind !== ReferenceKind.MANY_TO_ONE &&
|
|
1199
|
+
if (prop.kind !== ReferenceKind.MANY_TO_ONE &&
|
|
1200
|
+
prop.kind !== ReferenceKind.ONE_TO_ONE &&
|
|
1201
|
+
prop.kind !== ReferenceKind.ONE_TO_MANY &&
|
|
1202
|
+
prop.kind !== ReferenceKind.MANY_TO_MANY) {
|
|
1195
1203
|
return false;
|
|
1196
1204
|
}
|
|
1197
1205
|
const aRoot = this.#metadata.getByClassName(prop.type, false)?.root;
|
|
@@ -1247,7 +1255,14 @@ export class MetadataDiscovery {
|
|
|
1247
1255
|
// cleared implicitly when the first child claims the root property via
|
|
1248
1256
|
// addProperty below, so subsequent children correctly trigger renaming.
|
|
1249
1257
|
const typesMatch = rootProp?.type === prop.type || rootProp?.stiMerged === true || narrowedRelationOverride;
|
|
1258
|
+
// Inverse-side relations (1:m, inverse m:n) have no FK column on this
|
|
1259
|
+
// entity, so the rename branch — which exists to disambiguate physical
|
|
1260
|
+
// columns shared across STI children — doesn't apply. Skipping it also
|
|
1261
|
+
// avoids crashing on `[...rootProp.fieldNames]` since fieldNames is
|
|
1262
|
+
// never populated for inverse-side properties.
|
|
1263
|
+
const isInverseSideRelation = prop.kind === ReferenceKind.ONE_TO_MANY || (prop.kind === ReferenceKind.MANY_TO_MANY && !prop.owner);
|
|
1250
1264
|
if (rootProp &&
|
|
1265
|
+
!isInverseSideRelation &&
|
|
1251
1266
|
(!typesMatch ||
|
|
1252
1267
|
(rootProp.fieldNames && prop.fieldNames && !compareArrays(rootProp.fieldNames, prop.fieldNames)))) {
|
|
1253
1268
|
const name = newProp.name;
|
|
@@ -1302,6 +1317,14 @@ export class MetadataDiscovery {
|
|
|
1302
1317
|
if (narrowedRelationOverride) {
|
|
1303
1318
|
return;
|
|
1304
1319
|
}
|
|
1320
|
+
// STI siblings can declare the same property name on inverse-side relations
|
|
1321
|
+
// pointing to disjoint targets (e.g. `Dog.items → DogItem` and
|
|
1322
|
+
// `Cat.items → CatItem` with no shared base). There's no physical column
|
|
1323
|
+
// to manage at root, and propagating would clobber the first child's
|
|
1324
|
+
// declaration; each child keeps its local typed property instead.
|
|
1325
|
+
if (isInverseSideRelation && rootProp && rootProp.type !== prop.type) {
|
|
1326
|
+
return;
|
|
1327
|
+
}
|
|
1305
1328
|
meta.root.addProperty(newProp);
|
|
1306
1329
|
});
|
|
1307
1330
|
meta.tableName = meta.root.tableName;
|
|
@@ -160,7 +160,7 @@ export class MetadataValidator {
|
|
|
160
160
|
* Composite unique constraints are not sufficient for targetKey.
|
|
161
161
|
*/
|
|
162
162
|
isPropertyUnique(prop, meta) {
|
|
163
|
-
if (prop.unique) {
|
|
163
|
+
if (prop.unique || (prop.primary && meta.primaryKeys.length === 1)) {
|
|
164
164
|
return true;
|
|
165
165
|
}
|
|
166
166
|
// Check for single-property unique constraint via @Unique decorator
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.14-dev.0",
|
|
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
|
@@ -141,7 +141,7 @@ export function parseJsonSafe(value) {
|
|
|
141
141
|
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
142
142
|
export class Utils {
|
|
143
143
|
static PK_SEPARATOR = '~~~';
|
|
144
|
-
static #ORM_VERSION = '7.0.
|
|
144
|
+
static #ORM_VERSION = '7.0.14-dev.0';
|
|
145
145
|
/**
|
|
146
146
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
147
147
|
*/
|