Hi Ricardo,
I have similar feelings as you do that it’s not right as is.
I believe the original author had in their mind “a perfect copy” - meaning that if there was something the copy got from awakeFromInsertion “for free” then it isn’t really a copy of the source… so the author asked us to nullify.
That said, there are issues with the current state of affairs:
1) “Nullify” for a toMany relationship should not set it to “null” - it should at least set it to an empty array. Having it “null” can cause us gas because we are not expecting toMany relationships to ever be null… they can be empty arrays but not null.
2) “Skip” is valid for attributes, why not have it valid for relationships? If we “skip” then we can leave it alone. For some reason, the author expressly didn’t want relationships to be skipped. It’s presently a syntax error.
Cheers, — Aaron
I think ERXCopyable.java: 1286 should be changed to something like this:
case NULLIFY: // Only set to-one relationships to null. For to-many relationships we leave it alone with the empty array setup during the creation of the EO if (!relationship.isToMany()) { destination.takeStoredValueForKey(null, relationshipName); }
Hello everyone,
I like that in Wonder when you create an EO all the to-many relationships are initialized to an empty array because it means that I don’t have to worry about null checking every time I access the to-many relationship in order to avoid NullPointerExceptions.
However, if I create my EO by copying an existing one using ERXCopyable then any to-many relationships that have ERXCopyable.CopyType set to Nullify will be set to null.
Wouldn’t it be better to set them to an empty array? Or should we have an Emptify option?
Thanks Ricardo Parada
|