You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Hi, First of all, I'm not goot at English.. sorry.
I'm found problem in one-to-many and many-to-one relations. If add one item in collection, then id is defined after call persist and flush. But if add mulit item in collection, then ids aren't defined after call persist and flush. this is my repo
test("one-to-many - if make one book and persist, then book id is defined", async () => {
// given
const author = new Author();
author.setName("test");
const book1 = new Book();
book1.setName("book1");
const book2 = new Book();
book2.setName("book2");
const book3 = new Book();
book3.setName("book3");
book1.setAuthor(author);
author.addBook(book1);
// when
em.persist(author);
await em.flush();
// then
expect(book1.getId()).toBeDefined();
});
test("one-to-many - if make three book and persist, then book ids aren't defined", async () => {
// given
const author = new Author();
author.setName("test");
const book1 = new Book();
book1.setName("book1");
const book2 = new Book();
book2.setName("book2");
const book3 = new Book();
book3.setName("book3");
book1.setAuthor(author);
author.addBook(book1);
book2.setAuthor(author);
author.addBook(book2);
book3.setAuthor(author);
author.addBook(book3);
// when
em.persist(author);
await em.flush();
// then
expect(book1.getId()).toBeUndefined();
});
Expected behavior
I think that ids must be defined in both cases.
Versions
Dependency
Version
node
17.7.1
typescript
4.5.2
mikro-orm
^5.1.1
@mikro-orm/mysql
^5.1.1
The text was updated successfully, but these errors were encountered:
Describe the bug
Hi, First of all, I'm not goot at English.. sorry.
I'm found problem in one-to-many and many-to-one relations. If add one item in collection, then id is defined after call persist and flush. But if add mulit item in collection, then ids aren't defined after call persist and flush. this is my repo
Stack trace
My Entity
Test case
Expected behavior
I think that ids must be defined in both cases.
Versions
The text was updated successfully, but these errors were encountered: