Mailing List webobjects-dev@wocommunity.org Message #116
From: Aaron Rosenzweig <webobjects-dev@wocommunity.org>
Subject: Re: [WO-DEV] ERXCopyable.CopyType = Nullify on to-many relationship should empty instead
Date: Thu, 25 Mar 2021 13:35:24 -0400
To: WebObjects & WOnder Development <webobjects-dev@wocommunity.org>
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

On Mar 25, 2021, at 1:25 PM, Ricardo Parada <webobjects-dev@wocommunity.org> wrote:

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);
    }




On Mar 25, 2021, at 1:02 PM, Ricardo Parada <webobjects-dev@wocommunity.org> wrote:

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

Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster