@mikro-orm/core 6.6.1-dev.9 → 6.6.2-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.
@@ -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;
@@ -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
- prop.customType = new prop.type();
1138
- prop.type = prop.customType.constructor.name;
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.9",
3
+ "version": "6.6.2-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
  "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.9",
67
+ "mikro-orm": "6.6.2-dev.0",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -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
@@ -17,9 +17,6 @@ class BlobType extends Uint8ArrayType_1.Uint8ArrayType {
17
17
  compareAsType() {
18
18
  return 'Buffer';
19
19
  }
20
- ensureComparable() {
21
- return false;
22
- }
23
20
  getColumnType(prop, platform) {
24
21
  return platform.getBlobDeclarationSQL();
25
22
  }
@@ -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
  }
@@ -9,6 +9,9 @@ class BooleanType extends Type_1.Type {
9
9
  compareAsType() {
10
10
  return 'boolean';
11
11
  }
12
+ convertToJSValue(value) {
13
+ return Boolean(value);
14
+ }
12
15
  ensureComparable() {
13
16
  return false;
14
17
  }
@@ -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
  }
@@ -27,9 +27,6 @@ class Uint8ArrayType extends Type_1.Type {
27
27
  compareAsType() {
28
28
  return 'Buffer';
29
29
  }
30
- ensureComparable() {
31
- return false;
32
- }
33
30
  getColumnType(prop, platform) {
34
31
  return platform.getBlobDeclarationSQL();
35
32
  }
@@ -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: string): SnapshotGenerator<T>;
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;