@mikro-orm/core 7.0.0-dev.23 → 7.0.0-dev.25

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/EntityManager.js CHANGED
@@ -510,7 +510,7 @@ export class EntityManager {
510
510
  for (const e of fork.unitOfWork.getIdentityMap()) {
511
511
  const ref = em.getReference(e.constructor.name, helper(e).getPrimaryKey());
512
512
  const data = this.comparator.prepareEntity(e);
513
- em.config.getHydrator(this.metadata).hydrate(ref, helper(ref).__meta, helper(e).serialize({ ignoreSerializers: true }), em.entityFactory, 'full', false, true);
513
+ em.config.getHydrator(this.metadata).hydrate(ref, helper(ref).__meta, helper(e).serialize({ ignoreSerializers: true, includeHidden: true }), em.entityFactory, 'full', false, true);
514
514
  helper(ref).__originalEntityData = data;
515
515
  }
516
516
  }
@@ -36,7 +36,7 @@ export interface AssignOptions<Convert extends boolean> {
36
36
  */
37
37
  onlyProperties?: boolean;
38
38
  /**
39
- * With `onlyOwnProperties` enabled, to-many relations are skipped, and payloads of to-one relations are converted
39
+ * With `onlyOwnProperties` enabled, inverse sides of to-many relations are skipped, and payloads of other relations are converted
40
40
  * to foreign keys. Defaults to `false`.
41
41
  */
42
42
  onlyOwnProperties?: boolean;
@@ -42,9 +42,17 @@ export class EntityAssigner {
42
42
  }
43
43
  const prop = { ...props[propName], name: propName };
44
44
  if (prop && options.onlyOwnProperties) {
45
- if ([ReferenceKind.MANY_TO_MANY, ReferenceKind.ONE_TO_MANY].includes(prop.kind)) {
45
+ if ([ReferenceKind.ONE_TO_MANY].includes(prop.kind)) {
46
46
  return;
47
47
  }
48
+ if ([ReferenceKind.MANY_TO_MANY].includes(prop.kind)) {
49
+ if (!prop.owner) {
50
+ return;
51
+ }
52
+ else if (value?.map) {
53
+ value = value.map((v) => Utils.extractPK(v, prop.targetMeta));
54
+ }
55
+ }
48
56
  if ([ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind)) {
49
57
  value = Utils.extractPK(value, prop.targetMeta);
50
58
  }
@@ -378,7 +378,7 @@ export class ReferenceOptionsBuilder extends PropertyOptionsBuilder {
378
378
  * @internal
379
379
  * re-declare to override type inference
380
380
  */
381
- /* istanbul ignore next */
381
+ /* v8 ignore next 3 */
382
382
  ref(ref = true) {
383
383
  return new ReferenceOptionsBuilder({ ...this['~options'], ref });
384
384
  }
@@ -386,7 +386,7 @@ export class ReferenceOptionsBuilder extends PropertyOptionsBuilder {
386
386
  * @internal
387
387
  * re-declare to override type inference
388
388
  */
389
- /* istanbul ignore next */
389
+ /* v8 ignore next 3 */
390
390
  primary(primary = true) {
391
391
  return new ReferenceOptionsBuilder({ ...this['~options'], primary });
392
392
  }
package/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * @packageDocumentation
3
3
  * @module core
4
4
  */
5
- export { Constructor, ConnectionType, Dictionary, PrimaryKeyProp, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, EntityMetadata, QBFilterQuery, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, EntityRepositoryType, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, EntityClassGroup, OptionalProps, EagerProps, HiddenProps, RequiredEntityData, CheckCallback, IndexCallback, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, EntityDataValue, FilterKey, Opt, EntityType, FromEntityType, Selected, IsSubset, NoInfer, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, Hidden, FilterValue, MergeLoaded, MergeSelected, Config, DefineConfig, TypeConfig, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, } from './typings.js';
5
+ export { Constructor, ConnectionType, Dictionary, PrimaryKeyProp, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, EntityMetadata, QBFilterQuery, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, EntityRepositoryType, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, EntityClassGroup, OptionalProps, EagerProps, HiddenProps, RequiredEntityData, CheckCallback, IndexCallback, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, EntityDataValue, FilterKey, Opt, EntityType, FromEntityType, Selected, IsSubset, NoInfer, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, Hidden, FilterValue, MergeLoaded, MergeSelected, Config, DefineConfig, TypeConfig, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, RequiredNullable, } from './typings.js';
6
6
  export * from './enums.js';
7
7
  export * from './errors.js';
8
8
  export * from './exceptions.js';
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.23",
4
+ "version": "7.0.0-dev.25",
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",
@@ -52,9 +52,9 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "dataloader": "2.2.3",
55
- "dotenv": "17.2.1",
55
+ "dotenv": "17.2.2",
56
56
  "esprima": "4.0.1",
57
- "mikro-orm": "7.0.0-dev.23",
57
+ "mikro-orm": "7.0.0-dev.25",
58
58
  "reflect-metadata": "0.2.2",
59
59
  "tinyglobby": "0.2.13"
60
60
  }
@@ -17,6 +17,8 @@ export interface SerializeOptions<T, P extends string = never, E extends string
17
17
  forceObject?: boolean;
18
18
  /** Ignore custom property serializers. */
19
19
  ignoreSerializers?: boolean;
20
+ /** Include properties marked as `hidden`. */
21
+ includeHidden?: boolean;
20
22
  /** Skip properties with `null` value. */
21
23
  skipNull?: boolean;
22
24
  /** Only include properties for a specific group. If a property does not specify any group, it will be included, otherwise only properties with a matching group are included. */
@@ -15,7 +15,7 @@ function isVisible(meta, propName, options) {
15
15
  if (options.exclude?.find(item => item === propName)) {
16
16
  return false;
17
17
  }
18
- const visible = prop && !prop.hidden;
18
+ const visible = prop && !(prop.hidden && !options.includeHidden);
19
19
  const prefixed = prop && !prop.primary && propName.startsWith('_'); // ignore prefixed properties, if it's not a PK
20
20
  return visible && !prefixed;
21
21
  }
@@ -18,7 +18,7 @@ export class RawQueryFragment {
18
18
  }
19
19
  as(alias) {
20
20
  // TODO: to be removed in v7
21
- /* istanbul ignore next */
21
+ /* v8 ignore next 3 */
22
22
  if (alias.startsWith('`') || alias.startsWith('"')) {
23
23
  return new RawQueryFragment(`${this.sql} as ${alias}`, this.params);
24
24
  }
package/utils/Utils.js CHANGED
@@ -435,7 +435,11 @@ export class Utils {
435
435
  return data;
436
436
  }
437
437
  if (Utils.isEntity(data, true)) {
438
- return helper(data).getPrimaryKey();
438
+ const wrapped = helper(data);
439
+ if (wrapped.__meta.compositePK) {
440
+ return wrapped.getPrimaryKeys();
441
+ }
442
+ return wrapped.getPrimaryKey();
439
443
  }
440
444
  if (strict && meta && Utils.getObjectKeysSize(data) !== meta.primaryKeys.length) {
441
445
  return null;