Mailing List webobjects-dev@wocommunity.org Message #117
From: Ricardo Parada <webobjects-dev@wocommunity.org>
Subject: Re: [WO-DEV] Re: ERXCopyable.CopyType = Nullify on to-many relationship should empty instead
Date: Thu, 25 Mar 2021 14:11:50 -0400
To: WebObjects & WOnder Development <webobjects-dev@wocommunity.org>
I’m gonna play with it but I see a couple of things to advance this.

One is to have an ignoresToManyNullify property that defaults to false so that we don’t change the existing behavior. 

Then for us who don’t want to deal with null to-many relationships. We could set the property to true. 

Another option is to allow Skip to work on relationships. 

Thanks Aaron for the feedback. 

I think that code was written by David Avendasora. 

Ricardo


On Mar 25, 2021, at 1:35 PM, Aaron Rosenzweig <webobjects-dev@wocommunity.org> wrote:

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