@mikro-orm/core 7.0.0-dev.19 → 7.0.0-dev.20

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.
@@ -874,6 +874,7 @@ export class MetadataDiscovery {
874
874
  meta.properties[name].persist = false; // only virtual as we store the whole object
875
875
  meta.properties[name].userDefined = false; // mark this as a generated/internal property, so we can distinguish from user-defined non-persist properties
876
876
  meta.properties[name].object = true;
877
+ this.initCustomType(meta, meta.properties[name], true);
877
878
  }
878
879
  this.initEmbeddables(meta, meta.properties[name], visited);
879
880
  }
@@ -1100,7 +1101,7 @@ export class MetadataDiscovery {
1100
1101
  meta.concurrencyCheckKeys.add(prop.name);
1101
1102
  }
1102
1103
  }
1103
- initCustomType(meta, prop) {
1104
+ initCustomType(meta, prop, objectEmbeddable = false) {
1104
1105
  // `prop.type` might be actually instance of custom type class
1105
1106
  if (Type.isMappedType(prop.type) && !prop.customType) {
1106
1107
  prop.customType = prop.type;
@@ -1120,12 +1121,16 @@ export class MetadataDiscovery {
1120
1121
  if (!prop.customType && prop.array && prop.items) {
1121
1122
  prop.customType = new EnumArrayType(`${meta.className}.${prop.name}`, prop.items);
1122
1123
  }
1124
+ const isArray = prop.type?.toLowerCase() === 'array' || prop.type?.toString().endsWith('[]');
1125
+ if (objectEmbeddable && !prop.customType && isArray) {
1126
+ prop.customType = new JsonType();
1127
+ }
1123
1128
  // for number arrays we make sure to convert the items to numbers
1124
1129
  if (!prop.customType && prop.type === 'number[]') {
1125
1130
  prop.customType = new ArrayType(i => +i);
1126
1131
  }
1127
1132
  // `string[]` can be returned via ts-morph, while reflect metadata will give us just `array`
1128
- if (!prop.customType && (prop.type?.toLowerCase() === 'array' || prop.type?.toString().endsWith('[]'))) {
1133
+ if (!prop.customType && isArray) {
1129
1134
  prop.customType = new ArrayType();
1130
1135
  }
1131
1136
  if (!prop.customType && prop.type?.toLowerCase() === 'buffer') {
@@ -1166,7 +1171,7 @@ export class MetadataDiscovery {
1166
1171
  prop.customType.mode = prop.runtimeType.toLowerCase();
1167
1172
  }
1168
1173
  }
1169
- if (Type.isMappedType(prop.customType) && prop.kind === ReferenceKind.SCALAR && !prop.type?.toString().endsWith('[]')) {
1174
+ if (Type.isMappedType(prop.customType) && prop.kind === ReferenceKind.SCALAR && !isArray) {
1170
1175
  prop.type = prop.customType.name;
1171
1176
  }
1172
1177
  if (!prop.customType && [ReferenceKind.ONE_TO_ONE, ReferenceKind.MANY_TO_ONE].includes(prop.kind) && this.metadata.get(prop.type).compositePK) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.19",
4
+ "version": "7.0.0-dev.20",
5
5
  "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.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
@@ -56,7 +56,7 @@
56
56
  "dotenv": "16.5.0",
57
57
  "esprima": "4.0.1",
58
58
  "globby": "11.1.0",
59
- "mikro-orm": "7.0.0-dev.19",
59
+ "mikro-orm": "7.0.0-dev.20",
60
60
  "reflect-metadata": "0.2.2"
61
61
  }
62
62
  }