mikro-orm: v6: Incorrectly deep DTO population and related performance issue

Describe the bug When using a datastructure with circular references, toPOJO results in a performance issue and a object with incorrect depth

Stack trace N/A

To Reproduce Steps to reproduce the behavior:

  1. Create a circular reference in your entities: Author -> Books -> Author
  2. Query for the root entity and populate the dependency
  3. Convert to POJO and examine the populated depth and note the execution time

Repro

Expected behavior Only the loaded data will be populated in the DTO; the circular reference will stop with a a Reference instead of a populated DTO

Additional context Add any other context about the problem here.

Versions

Dependency Version
node 16.14.2
typescript 4.9.5
mikro-orm 6.0.0-dev.64

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 23 (23 by maintainers)

Most upvoted comments

Also teeny bit of feedback, it’s a little weird that the second arg for wrap (e.g., wrap(this, true)) is necessary and will result in a runtime error if it’s not there. I’m sure there’s a reason, but it’s a bit funky on the dev experience

What do you mean? There are tons of tests that are using just wrap without it, repro welcome, that sounds more like a bug.