1:M relationship weird behaviour when selecting specific fields explicitely #3012
Unanswered
swapnil-gawali
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Interesting, we recently started inferring Minimal repro: test('stable results of serialization with partial loading', async () => {
const god = new Author2('God', 'hello@heaven.god');
god.books.add(new Book2('Bible', god));
await orm.em.fork().persistAndFlush(god);
const newGod = await orm.em.findOneOrFail(Author2, god.id, {
populate: ['books'],
fields: [{ books: ['title'] }],
});
const json = wrap(newGod).toJSON();
expect(json.books[0].author).toBe(newGod.id);
}); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I am trying to fetch One-to-Many relation. But when we select fields explicitly, it populates relations recursively like
User-> Post -> User
. It works correctly if I am not selecting any field.Config
Expected behavior
The result should not contain user object in posts object.
Versions
Beta Was this translation helpful? Give feedback.
All reactions