@mikro-orm/core 6.3.5-dev.4 → 6.3.5-dev.6
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/hydration/ObjectHydrator.js +1 -1
- package/metadata/MetadataDiscovery.d.ts +0 -1
- package/metadata/MetadataDiscovery.js +2 -9
- package/package.json +2 -2
- package/platforms/Platform.d.ts +1 -0
- package/platforms/Platform.js +5 -0
- package/utils/Configuration.d.ts +1 -2
- package/utils/Configuration.js +1 -1
- package/utils/EntityComparator.js +1 -1
|
@@ -77,7 +77,7 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
77
77
|
else if (prop.runtimeType === 'boolean') {
|
|
78
78
|
ret.push(` entity${entityKey} = !!data${dataKey};`);
|
|
79
79
|
}
|
|
80
|
-
else if (prop.runtimeType === 'Date') {
|
|
80
|
+
else if (prop.runtimeType === 'Date' && !this.platform.isNumericProperty(prop)) {
|
|
81
81
|
ret.push(` if (data${dataKey} instanceof Date) {`);
|
|
82
82
|
ret.push(` entity${entityKey} = data${dataKey};`);
|
|
83
83
|
if (!tz || tz === 'local') {
|
|
@@ -920,7 +920,7 @@ class MetadataDiscovery {
|
|
|
920
920
|
}
|
|
921
921
|
initAutoincrement(meta) {
|
|
922
922
|
const pks = meta.getPrimaryProps();
|
|
923
|
-
if (pks.length === 1 && this.isNumericProperty(pks[0])) {
|
|
923
|
+
if (pks.length === 1 && this.platform.isNumericProperty(pks[0])) {
|
|
924
924
|
/* istanbul ignore next */
|
|
925
925
|
pks[0].autoincrement ??= true;
|
|
926
926
|
}
|
|
@@ -1226,7 +1226,7 @@ class MetadataDiscovery {
|
|
|
1226
1226
|
});
|
|
1227
1227
|
return;
|
|
1228
1228
|
}
|
|
1229
|
-
prop.unsigned ??= (prop.primary || prop.unsigned) && this.isNumericProperty(prop) && this.platform.supportsUnsigned();
|
|
1229
|
+
prop.unsigned ??= (prop.primary || prop.unsigned) && this.platform.isNumericProperty(prop) && this.platform.supportsUnsigned();
|
|
1230
1230
|
}
|
|
1231
1231
|
initIndexes(meta, prop) {
|
|
1232
1232
|
const hasIndex = meta.indexes.some(idx => idx.properties?.length === 1 && idx.properties[0] === prop.name);
|
|
@@ -1234,13 +1234,6 @@ class MetadataDiscovery {
|
|
|
1234
1234
|
prop.index ??= true;
|
|
1235
1235
|
}
|
|
1236
1236
|
}
|
|
1237
|
-
isNumericProperty(prop) {
|
|
1238
|
-
if (prop.customType) {
|
|
1239
|
-
return this.platform.isNumericColumn(prop.customType);
|
|
1240
|
-
}
|
|
1241
|
-
const numericMappedType = prop.columnTypes?.[0] && this.platform.isNumericColumn(this.platform.getMappedType(prop.columnTypes[0]));
|
|
1242
|
-
return numericMappedType || prop.type === 'number' || this.platform.isBigIntProperty(prop);
|
|
1243
|
-
}
|
|
1244
1237
|
async getEntityClassOrSchema(path, name) {
|
|
1245
1238
|
const exports = await Utils_1.Utils.dynamicImport(path);
|
|
1246
1239
|
const targets = Object.values(exports)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.3.5-dev.
|
|
3
|
+
"version": "6.3.5-dev.6",
|
|
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.5-dev.
|
|
67
|
+
"mikro-orm": "6.3.5-dev.6",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/platforms/Platform.d.ts
CHANGED
|
@@ -172,6 +172,7 @@ export declare abstract class Platform {
|
|
|
172
172
|
setConfig(config: Configuration): void;
|
|
173
173
|
getConfig(): Configuration;
|
|
174
174
|
getTimezone(): string | undefined;
|
|
175
|
+
isNumericProperty(prop: EntityProperty, ignoreCustomType?: boolean): boolean;
|
|
175
176
|
isNumericColumn(mappedType: Type<unknown>): boolean;
|
|
176
177
|
supportsUnsigned(): boolean;
|
|
177
178
|
/**
|
package/platforms/Platform.js
CHANGED
|
@@ -300,6 +300,7 @@ class Platform {
|
|
|
300
300
|
}
|
|
301
301
|
parseDate(value) {
|
|
302
302
|
const date = new Date(value);
|
|
303
|
+
/* istanbul ignore next */
|
|
303
304
|
if (isNaN(date.getTime())) {
|
|
304
305
|
return value;
|
|
305
306
|
}
|
|
@@ -415,6 +416,10 @@ class Platform {
|
|
|
415
416
|
getTimezone() {
|
|
416
417
|
return this.timezone;
|
|
417
418
|
}
|
|
419
|
+
isNumericProperty(prop, ignoreCustomType = false) {
|
|
420
|
+
const numericMappedType = prop.columnTypes?.[0] && this.isNumericColumn(this.getMappedType(prop.columnTypes[0]));
|
|
421
|
+
return numericMappedType || prop.type === 'number' || this.isBigIntProperty(prop);
|
|
422
|
+
}
|
|
418
423
|
isNumericColumn(mappedType) {
|
|
419
424
|
return [types_1.IntegerType, types_1.SmallIntType, types_1.BigIntType, types_1.TinyIntType].some(t => mappedType instanceof t);
|
|
420
425
|
}
|
package/utils/Configuration.d.ts
CHANGED
|
@@ -72,7 +72,6 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
|
|
|
72
72
|
persistOnCreate: true;
|
|
73
73
|
forceEntityConstructor: false;
|
|
74
74
|
forceUndefined: false;
|
|
75
|
-
forceUtcTimezone: false;
|
|
76
75
|
ensureDatabase: true;
|
|
77
76
|
ensureIndexes: false;
|
|
78
77
|
batchSize: number;
|
|
@@ -330,7 +329,7 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
|
|
|
330
329
|
persistOnCreate: boolean;
|
|
331
330
|
forceEntityConstructor: boolean | (Constructor<AnyEntity> | string)[];
|
|
332
331
|
forceUndefined: boolean;
|
|
333
|
-
forceUtcTimezone
|
|
332
|
+
forceUtcTimezone?: boolean;
|
|
334
333
|
timezone?: string;
|
|
335
334
|
ensureDatabase: boolean | EnsureDatabaseOptions;
|
|
336
335
|
ensureIndexes: boolean;
|
package/utils/Configuration.js
CHANGED
|
@@ -67,7 +67,6 @@ class Configuration {
|
|
|
67
67
|
persistOnCreate: true,
|
|
68
68
|
forceEntityConstructor: false,
|
|
69
69
|
forceUndefined: false,
|
|
70
|
-
forceUtcTimezone: false,
|
|
71
70
|
ensureDatabase: true,
|
|
72
71
|
ensureIndexes: false,
|
|
73
72
|
batchSize: 300,
|
|
@@ -214,6 +213,7 @@ class Configuration {
|
|
|
214
213
|
this.cache.set(name, ext());
|
|
215
214
|
return this.cache.get(name);
|
|
216
215
|
}
|
|
216
|
+
/* istanbul ignore next */
|
|
217
217
|
return undefined;
|
|
218
218
|
}
|
|
219
219
|
/**
|
|
@@ -300,7 +300,7 @@ class EntityComparator {
|
|
|
300
300
|
lines.push(` ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
|
|
301
301
|
lines.push(` }`);
|
|
302
302
|
}
|
|
303
|
-
else if (prop.runtimeType === 'Date') {
|
|
303
|
+
else if (prop.runtimeType === 'Date' && !this.platform.isNumericProperty(prop)) {
|
|
304
304
|
lines.push(` if (typeof ${this.propName(prop.fieldNames[0])} !== 'undefined') {`);
|
|
305
305
|
context.set('parseDate', (value) => this.platform.parseDate(value));
|
|
306
306
|
parseDate('ret' + this.wrap(prop.name), this.propName(prop.fieldNames[0]));
|