Replies: 2 comments
-
What is weird about this? Your
This is a no-go to me, the entity instance needs to be valid at all time, and here you'd literally like to create an incomplete one. The I am not against the latter, but I am not interested in implementing it either (so nope, don't create a new issue for that :]). Feel free to give that a try if you think it's that important, but hear me out, it will be very tricky. Propagation is implemented on the entity level, where we know everything about the metadata. If you want this to work, you'd probably have to implement it on POJOs too. The current implementation is simply not developed to support this, it actually proactively validates you don't do this.
I feel like you are still missing one important thing. Those two lines are doing the same: member.groups.set([orm.em.create(GroupMember, { group: group1, member })]);
// this line on its own is the same, as the `GroupMember.member` value is propagated to `member.groups` automatically
orm.em.create(GroupMember, { group: group1, member }); (or not exactly the same, the latter is adding to the |
Beta Was this translation helpful? Give feedback.
-
I am starting to change my mind around the second idea - both in What changed it was one test where I ended up with pretty much the same problem - I tried to introduce the reference wrapper to a project, the entity in question has a constructor requiring a I would gradually like to push the reference wrapper more, maybe even thinking of making it the default way in v6. And for that things like the above need to work. (my stance about the |
Beta Was this translation helpful? Give feedback.
-
I was looking at the tests from GH3599 and saw that when adding new groups to a member, you still have to specify the member id. To illustrate the example a little better these are the entities:
When assigning a new group to a member you have to do it like this:
It seems unnecessary to me to specify
member
again. We already know thatmember
is going to be a value of the second primary key, since we are setting the groups on a specific member. However, since we are usingem.create
which create a new instance ofGroupMember
first, before setting it, I can understand this.Then we have
em.assign
. We assign new groups to a member like this:This definitely seems weird to me. Why do I need to specify
member
again, I am already assigning this group tomember. Sure, underneath it probably calls the same methods are
Collection.set`, but it seems unnecessary to me.My idea is to have the assignment we without the relation property we are assigning it to.
Let me know what you think.
Beta Was this translation helpful? Give feedback.
All reactions