Makes sense to me. David has worked on this most recently, he may have had a
specific use case in mind for the null.
Chuck
On 2015-01-07, 9:54 AM, "Ricardo Parada" wrote:
Hi David A., Chuck or anybody knowledgable about ERXCopyable,
Since I started using Wonder I noticed that when an EO is created and inserted
into the editing context the to-many relationships have an empty array. I
really like this because it eliminated a lot of null checking logic before
accessing to many relationships, I.e. I can do myToMany().count() without fear
that I will get a null pointer exception.
I started using ERXCopyable and like it very much. In one of my EO's I have a
special to-many relationship where the objects in it have to be copied over in
a specific order. Therefore, I specified the Nullify copy type for that
to-many. That sets the to-many to null. I then wrote the custom logic to copy
the objects in the to-many in the correct order. However, I encountered a null
pointer exception because the to-many is null and the code written it assumes
that the to-many starts out with an empty array.
It's no big deal as I can work around it. However, it made me think that maybe
the Nullify copy type should leave to-many relationships alone instead of
setting them to null. Something like this:
...
case NULLIFY:
// Null out the to-one and leave to-many as is so that it remains as an empty
array
if (relationship.isToMany() == false) {
destination.takeStoredValueForKey(null, relationshipName);
}
break;
...
Let me know what you think.
Thanks,
Ricardo Parada
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]