@mikro-orm/core 7.1.0-dev.20 → 7.1.0-dev.21
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);
|
|
@@ -1389,10 +1394,10 @@ export class MetadataDiscovery {
|
|
|
1389
1394
|
if (meta.root !== meta) {
|
|
1390
1395
|
meta.root = metadata.find(m => m.class === meta.root.class);
|
|
1391
1396
|
}
|
|
1392
|
-
|
|
1393
|
-
if (inheritance === 'tpt' && meta.root
|
|
1394
|
-
meta.inheritanceType = 'tpt';
|
|
1395
|
-
meta.tptChildren
|
|
1397
|
+
// init the root eagerly so children iterated before the root (e.g. alphabetical glob order) still get linked
|
|
1398
|
+
if (meta.root.inheritance === 'tpt' && meta.root.inheritanceType !== 'tpt') {
|
|
1399
|
+
meta.root.inheritanceType = 'tpt';
|
|
1400
|
+
meta.root.tptChildren ??= [];
|
|
1396
1401
|
}
|
|
1397
1402
|
if (meta.root.inheritanceType !== 'tpt') {
|
|
1398
1403
|
return;
|
|
@@ -348,7 +348,7 @@ export class MetadataValidator {
|
|
|
348
348
|
* Composite unique constraints are not sufficient for targetKey.
|
|
349
349
|
*/
|
|
350
350
|
isPropertyUnique(prop, meta) {
|
|
351
|
-
if (prop.unique) {
|
|
351
|
+
if (prop.unique || (prop.primary && meta.primaryKeys.length === 1)) {
|
|
352
352
|
return true;
|
|
353
353
|
}
|
|
354
354
|
// 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.1.0-dev.
|
|
3
|
+
"version": "7.1.0-dev.21",
|
|
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/platforms/Platform.d.ts
CHANGED
|
@@ -170,7 +170,7 @@ export declare abstract class Platform {
|
|
|
170
170
|
getUuidTypeDeclarationSQL(column: {
|
|
171
171
|
length?: number;
|
|
172
172
|
}): string;
|
|
173
|
-
/** Extracts the base type name from a full SQL type declaration (e.g.
|
|
173
|
+
/** Extracts the base type name from a full SQL type declaration (e.g. `varchar(255)` -> `varchar`). */
|
|
174
174
|
extractSimpleType(type: string): string;
|
|
175
175
|
/**
|
|
176
176
|
* This should be used only to compare types, it can strip some information like the length.
|
package/platforms/Platform.js
CHANGED
|
@@ -9,6 +9,15 @@ import { ReferenceKind } from '../enums.js';
|
|
|
9
9
|
import { Raw } from '../utils/RawQueryFragment.js';
|
|
10
10
|
/** Symbol used to tag cloned embeddable data for JSON serialization handling. */
|
|
11
11
|
export const JsonProperty = Symbol('JsonProperty');
|
|
12
|
+
const MULTI_WORD_SQL_TYPES = [
|
|
13
|
+
'timestamp with time zone',
|
|
14
|
+
'timestamp without time zone',
|
|
15
|
+
'time with time zone',
|
|
16
|
+
'time without time zone',
|
|
17
|
+
'character varying',
|
|
18
|
+
'double precision',
|
|
19
|
+
'bit varying',
|
|
20
|
+
];
|
|
12
21
|
/** Abstract base class providing database-specific behavior and SQL dialect differences. */
|
|
13
22
|
export class Platform {
|
|
14
23
|
exceptionConverter = new ExceptionConverter();
|
|
@@ -227,9 +236,15 @@ export class Platform {
|
|
|
227
236
|
column.length ??= 36;
|
|
228
237
|
return this.getVarcharTypeDeclarationSQL(column);
|
|
229
238
|
}
|
|
230
|
-
/** Extracts the base type name from a full SQL type declaration (e.g.
|
|
239
|
+
/** Extracts the base type name from a full SQL type declaration (e.g. `varchar(255)` -> `varchar`). */
|
|
231
240
|
extractSimpleType(type) {
|
|
232
|
-
|
|
241
|
+
const lower = type.toLowerCase();
|
|
242
|
+
for (const multiWord of MULTI_WORD_SQL_TYPES) {
|
|
243
|
+
if (lower.startsWith(multiWord)) {
|
|
244
|
+
return multiWord;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return /[^(), ]+/.exec(lower)[0];
|
|
233
248
|
}
|
|
234
249
|
/**
|
|
235
250
|
* This should be used only to compare types, it can strip some information like the length.
|
|
@@ -253,6 +268,7 @@ export class Platform {
|
|
|
253
268
|
return Type.getType(CharacterType);
|
|
254
269
|
case 'string':
|
|
255
270
|
case 'varchar':
|
|
271
|
+
case 'character varying':
|
|
256
272
|
return Type.getType(StringType);
|
|
257
273
|
case 'interval':
|
|
258
274
|
return Type.getType(IntervalType);
|
|
@@ -272,6 +288,7 @@ export class Platform {
|
|
|
272
288
|
case 'float':
|
|
273
289
|
return Type.getType(FloatType);
|
|
274
290
|
case 'double':
|
|
291
|
+
case 'double precision':
|
|
275
292
|
return Type.getType(DoubleType);
|
|
276
293
|
case 'integer':
|
|
277
294
|
return Type.getType(IntegerType);
|
|
@@ -291,8 +308,12 @@ export class Platform {
|
|
|
291
308
|
return Type.getType(DateType);
|
|
292
309
|
case 'datetime':
|
|
293
310
|
case 'timestamp':
|
|
311
|
+
case 'timestamp with time zone':
|
|
312
|
+
case 'timestamp without time zone':
|
|
294
313
|
return Type.getType(DateTimeType);
|
|
295
314
|
case 'time':
|
|
315
|
+
case 'time with time zone':
|
|
316
|
+
case 'time without time zone':
|
|
296
317
|
return Type.getType(TimeType);
|
|
297
318
|
case 'object':
|
|
298
319
|
case 'json':
|
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.1.0-dev.
|
|
144
|
+
static #ORM_VERSION = '7.1.0-dev.21';
|
|
145
145
|
/**
|
|
146
146
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
147
147
|
*/
|