-
-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
- Given we are using Entity Schema definitions
- And we have a
Company
entity class with its schema - And a
Company
has manyUser
's - And a
User
has manyProfile
's - And we have a Company "Acme" that has "User1" and "User2" as users
- And "User1" has two profiles
- And "User2" has one profile
- When we try to fetch the
Company
from the database, populating bothuser
andprofile
- Then the "User2" has three profiles associated.
The Diagram below illustrates that:
flowchart LR
A[Company 'A'] -->|Has| B(User 1)
A[Company 'A'] -->|Has| C(User 2)
B --> |Has| D(Profile 1)
B --> |Has| E(Profile 2)
C --> |Has| F(Profile 3)
Stack trace
AssertionError: expected { Object (0, 1, ...) } to have a length of 1 but got 3
- Expected
+ Received
- 1
+ 3
❯ src/mikro-orm/mikro-orm-internal.module.spec.ts:100:45
98| // Assert
99| const userWithASingleProfile = companyWithProfiles.users.find(u => u.id === user2.id);
100| expect(userWithASingleProfile.profiles).toHaveLength(1);
| ^
101| });
102|
To Reproduce
Steps to reproduce the behavior:
- Clone the minimum reproducible code repository: https://github.com/thiagomini/nest-mikro-orm-example/tree/bug/nested-populated-entities
- run
yarn
- run
docker compose up -d
- run
yarn test
Expected behavior
"User2" should have only ONE associated Profile.
Additional Information
Versions
Dependency | Version |
---|---|
node | 18.12.1 |
typescript | 5.2.2 |
mikro-orm | 5.8.3 |
pg | 8.11.2 |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working