@mikro-orm/core 6.6.1-dev.1 → 6.6.1-dev.11
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/README.md +2 -0
- package/drivers/DatabaseDriver.d.ts +1 -0
- package/drivers/DatabaseDriver.js +9 -0
- package/metadata/MetadataDiscovery.js +14 -4
- package/package.json +2 -2
- package/types/BlobType.d.ts +0 -1
- package/types/BlobType.js +0 -3
- package/types/BooleanType.d.ts +1 -0
- package/types/BooleanType.js +3 -0
- package/types/Uint8ArrayType.d.ts +0 -1
- package/types/Uint8ArrayType.js +0 -3
- package/unit-of-work/ChangeSetPersister.js +16 -5
- package/utils/EntityComparator.d.ts +2 -2
- package/utils/EntityComparator.js +1 -0
package/README.md
CHANGED
|
@@ -383,6 +383,8 @@ See also the list of contributors who [participated](https://github.com/mikro-or
|
|
|
383
383
|
|
|
384
384
|
Please ⭐️ this repository if this project helped you!
|
|
385
385
|
|
|
386
|
+
> If you'd like to support my open-source work, consider sponsoring me directly at [github.com/sponsors/b4nan](https://github.com/sponsors/b4nan).
|
|
387
|
+
|
|
386
388
|
## 📝 License
|
|
387
389
|
|
|
388
390
|
Copyright © 2018 [Martin Adámek](https://github.com/b4nan).
|
|
@@ -43,6 +43,7 @@ export declare abstract class DatabaseDriver<C extends Connection> implements ID
|
|
|
43
43
|
setMetadata(metadata: MetadataStorage): void;
|
|
44
44
|
getMetadata(): MetadataStorage;
|
|
45
45
|
getDependencies(): string[];
|
|
46
|
+
protected isPopulated<T extends object>(meta: EntityMetadata<T>, prop: EntityProperty<T>, hint: PopulateOptions<T>, name?: string): boolean;
|
|
46
47
|
protected processCursorOptions<T extends object, P extends string>(meta: EntityMetadata<T>, options: FindOptions<T, P, any, any>, orderBy: OrderDefinition<T>): {
|
|
47
48
|
orderBy: OrderDefinition<T>[];
|
|
48
49
|
where: FilterQuery<T>;
|
|
@@ -107,6 +107,15 @@ class DatabaseDriver {
|
|
|
107
107
|
getDependencies() {
|
|
108
108
|
return this.dependencies;
|
|
109
109
|
}
|
|
110
|
+
isPopulated(meta, prop, hint, name) {
|
|
111
|
+
if (hint.field === prop.name || hint.field === name || hint.all) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
if (prop.embedded && hint.children && meta.properties[prop.embedded[0]].name === hint.field) {
|
|
115
|
+
return hint.children.some(c => this.isPopulated(meta, prop, c, prop.embedded[1]));
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
110
119
|
processCursorOptions(meta, options, orderBy) {
|
|
111
120
|
const { first, last, before, after, overfetch } = options;
|
|
112
121
|
const limit = first ?? last;
|
|
@@ -1057,7 +1057,7 @@ class MetadataDiscovery {
|
|
|
1057
1057
|
return '1';
|
|
1058
1058
|
}
|
|
1059
1059
|
inferDefaultValue(meta, prop) {
|
|
1060
|
-
if (!meta.class
|
|
1060
|
+
if (!meta.class) {
|
|
1061
1061
|
return;
|
|
1062
1062
|
}
|
|
1063
1063
|
try {
|
|
@@ -1066,7 +1066,7 @@ class MetadataDiscovery {
|
|
|
1066
1066
|
const entity1 = new meta.class();
|
|
1067
1067
|
const entity2 = new meta.class();
|
|
1068
1068
|
// we compare the two values by reference, this will discard things like `new Date()` or `Date.now()`
|
|
1069
|
-
if (prop.default === undefined && entity1[prop.name] != null && entity1[prop.name] === entity2[prop.name] && entity1[prop.name] !== now) {
|
|
1069
|
+
if (this.config.get('discovery').inferDefaultValues && prop.default === undefined && entity1[prop.name] != null && entity1[prop.name] === entity2[prop.name] && entity1[prop.name] !== now) {
|
|
1070
1070
|
prop.default ??= entity1[prop.name];
|
|
1071
1071
|
}
|
|
1072
1072
|
// if the default value is null, infer nullability
|
|
@@ -1134,8 +1134,18 @@ class MetadataDiscovery {
|
|
|
1134
1134
|
}
|
|
1135
1135
|
// `prop.type` might also be custom type class (not instance), so `typeof MyType` will give us `function`, not `object`
|
|
1136
1136
|
if (typeof prop.type === 'function' && types_1.Type.isMappedType(prop.type.prototype) && !prop.customType) {
|
|
1137
|
-
|
|
1138
|
-
|
|
1137
|
+
// if the type is an ORM defined mapped type without `ensureComparable: true`,
|
|
1138
|
+
// we use just the type name, to have more performant hydration code
|
|
1139
|
+
const type = Utils_1.Utils.keys(types_1.t).find(type => {
|
|
1140
|
+
return !types_1.Type.getType(types_1.t[type]).ensureComparable(meta, prop) && prop.type === types_1.t[type];
|
|
1141
|
+
});
|
|
1142
|
+
if (type) {
|
|
1143
|
+
prop.type = type === 'datetime' ? 'Date' : type;
|
|
1144
|
+
}
|
|
1145
|
+
else {
|
|
1146
|
+
prop.customType = new prop.type();
|
|
1147
|
+
prop.type = prop.customType.constructor.name;
|
|
1148
|
+
}
|
|
1139
1149
|
}
|
|
1140
1150
|
if (simple) {
|
|
1141
1151
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.6.1-dev.
|
|
3
|
+
"version": "6.6.1-dev.11",
|
|
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.3.2",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.6.1-dev.
|
|
67
|
+
"mikro-orm": "6.6.1-dev.11",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/types/BlobType.d.ts
CHANGED
|
@@ -4,6 +4,5 @@ import type { EntityProperty } from '../typings';
|
|
|
4
4
|
export declare class BlobType extends Uint8ArrayType {
|
|
5
5
|
convertToJSValue(value: Buffer): Buffer | null;
|
|
6
6
|
compareAsType(): string;
|
|
7
|
-
ensureComparable(): boolean;
|
|
8
7
|
getColumnType(prop: EntityProperty, platform: Platform): string;
|
|
9
8
|
}
|
package/types/BlobType.js
CHANGED
package/types/BooleanType.d.ts
CHANGED
|
@@ -4,5 +4,6 @@ import type { EntityProperty } from '../typings';
|
|
|
4
4
|
export declare class BooleanType extends Type<boolean | null | undefined, boolean | null | undefined> {
|
|
5
5
|
getColumnType(prop: EntityProperty, platform: Platform): string;
|
|
6
6
|
compareAsType(): string;
|
|
7
|
+
convertToJSValue(value: boolean | null | undefined): boolean | null | undefined;
|
|
7
8
|
ensureComparable(): boolean;
|
|
8
9
|
}
|
package/types/BooleanType.js
CHANGED
|
@@ -5,6 +5,5 @@ export declare class Uint8ArrayType extends Type<Uint8Array | null> {
|
|
|
5
5
|
convertToDatabaseValue(value: Uint8Array): Buffer;
|
|
6
6
|
convertToJSValue(value: Buffer): Uint8Array | null;
|
|
7
7
|
compareAsType(): string;
|
|
8
|
-
ensureComparable(): boolean;
|
|
9
8
|
getColumnType(prop: EntityProperty, platform: Platform): string;
|
|
10
9
|
}
|
package/types/Uint8ArrayType.js
CHANGED
|
@@ -291,11 +291,22 @@ class ChangeSetPersister {
|
|
|
291
291
|
async reloadVersionValues(meta, changeSets, options) {
|
|
292
292
|
const reloadProps = meta.versionProperty && !this.usesReturningStatement ? [meta.properties[meta.versionProperty]] : [];
|
|
293
293
|
if (changeSets[0].type === ChangeSet_1.ChangeSetType.CREATE) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
.
|
|
294
|
+
for (const prop of meta.props) {
|
|
295
|
+
if (prop.persist === false) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (utils_1.Utils.isRawSql(changeSets[0].entity[prop.name])) {
|
|
299
|
+
reloadProps.push(prop);
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
// do not reload things that already had a runtime value
|
|
303
|
+
if (changeSets[0].entity[prop.name] != null || prop.defaultRaw === 'null') {
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if (prop.autoincrement || prop.generated || prop.defaultRaw) {
|
|
307
|
+
reloadProps.push(prop);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
299
310
|
}
|
|
300
311
|
if (changeSets[0].type === ChangeSet_1.ChangeSetType.UPDATE) {
|
|
301
312
|
const returning = new Set();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EntityData, EntityDictionary, EntityMetadata, EntityProperty, IMetadataStorage } from '../typings';
|
|
1
|
+
import type { EntityData, EntityDictionary, EntityMetadata, EntityName, EntityProperty, IMetadataStorage } from '../typings';
|
|
2
2
|
import type { Platform } from '../platforms';
|
|
3
3
|
type Comparator<T> = (a: T, b: T, options?: {
|
|
4
4
|
includeInverseSides?: boolean;
|
|
@@ -48,7 +48,7 @@ export declare class EntityComparator {
|
|
|
48
48
|
/**
|
|
49
49
|
* @internal Highly performance-sensitive method.
|
|
50
50
|
*/
|
|
51
|
-
getSnapshotGenerator<T>(entityName:
|
|
51
|
+
getSnapshotGenerator<T>(entityName: EntityName<T>): SnapshotGenerator<T>;
|
|
52
52
|
/**
|
|
53
53
|
* @internal
|
|
54
54
|
*/
|
|
@@ -202,6 +202,7 @@ class EntityComparator {
|
|
|
202
202
|
* @internal Highly performance-sensitive method.
|
|
203
203
|
*/
|
|
204
204
|
getSnapshotGenerator(entityName) {
|
|
205
|
+
entityName = Utils_1.Utils.className(entityName);
|
|
205
206
|
const exists = this.snapshotGenerators.get(entityName);
|
|
206
207
|
if (exists) {
|
|
207
208
|
return exists;
|