X-CGP-ClamAV-Result: CLEAN X-VirusScanner: Niversoft's CGPClamav Helper v1.22.2a (ClamAV engine v0.102.2) X-Junk-Score: 0 [] X-KAS-Score: 0 [] From: "Ricardo Parada" Received: from st43p00im-zteg10063501.me.com ([17.58.63.176] verified) by post.selbstdenker.com (CommuniGate Pro SMTP 6.3.3) with ESMTPS id 25700319 for webobjects-dev@wocommunity.org; Sat, 10 Apr 2021 00:32:44 +0200 Received-SPF: pass receiver=post.selbstdenker.com; client-ip=17.58.63.176; envelope-from=rparada@mac.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=1a1hai; t=1618007542; bh=LBgN+TJa4JH66Lp9Vw/uq6Awv5KxbnmdnEUfOGNY7pc=; h=Content-Type:From:Mime-Version:Subject:Date:Message-Id:To; b=ATixv/go6lIbxUgihADCOSck0GjRW0BRI+xdUmj4MOfdQDBhglSdlV7+CWZxezwVm uTtNb7XbDb27O2m2c3cDnIVoxTI4cfJ0rHDPxP4ePC20CvFdkjygWPoM+ZCMOVdXsf WWKD7gAOaEag/TJ6KDk8g5ChxCeBSkJEZ0HFJt2V+pkB8GI+QwTU7tMoTwHzkc5y2p APN/cKRpKj/aUsRBBGGT7dEjvuk5b/M1YiZk0VsxEhNYKvvC8aAc0aw4NtBF0vFahR 5uCjEM8THoEj2XNOt7sjavw9RE15TLFlbl8dBDGcAAHMsW2thPY8SbP1cV6KPf3UBt RT6upLCh0e58g== Received: from [IPv6:2607:fb90:92ed:bf38:a9e3:c47f:c6ed:2096] (unknown [172.58.11.82]) by st43p00im-zteg10063501.me.com (Postfix) with ESMTPSA id 65BFCC80679 for ; Fri, 9 Apr 2021 22:32:22 +0000 (UTC) Content-Type: multipart/alternative; boundary=Apple-Mail-3A7D00F8-9375-4B54-BE78-4BC4C96EAF0C Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (1.0) Subject: Re: [WO-DEV] Re: ERXCopyable.CopyType = Nullify on to-many relationship should empty instead Date: Fri, 9 Apr 2021 18:32:17 -0400 Message-Id: References: In-Reply-To: To: WebObjects & WOnder Development X-Mailer: iPhone Mail (18D70) X-Proofpoint-Virus-Version: =?UTF-8?Q?vendor=3Dfsecure_engine=3D1.1.170-22c6f66c430a71ce266a39bfe25bc?= =?UTF-8?Q?2903e8d5c8f:6.0.391,18.0.761,17.0.607.475.0000000_definitions?= =?UTF-8?Q?=3D2021-04-09=5F07:2021-04-09=5F01,2021-04-09=5F07,2020-04-07?= =?UTF-8?Q?=5F01_signatures=3D0?= X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 clxscore=1015 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2104090164 --Apple-Mail-3A7D00F8-9375-4B54-BE78-4BC4C96EAF0C Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Aaron, Got it. Thanks for the heads up.=20 Do you have any plans to submit a pull request for your fix?=20 Ricardo Parada=20 Sent from my iPhone > On Apr 1, 2021, at 10:02 AM, Aaron Rosenzweig wrote: >=20 > =EF=BB=BFRicardo (and friends) - heads up.=20 >=20 > We modified our local branch of WOnder to not null out the toMany relation= ship.=20 >=20 > We made an innocent mistake of setting an empty immutable NSArray.=20 >=20 > Even though most API methods return an interface of =E2=80=9CNSArray=E2=80= =9D internally the data structure is mutable. I believe the primary idea is t= hat people shouldn=E2=80=99t add/remove from the array directly. That said, i= nternally, you do need a mutable data structure.=20 >=20 > It must be an empty mutable NSMutableArray that you set. If you don=E2=80=99= t, when you try to add something to the toMany relationship it will fail.=20= >=20 >=20 >> On Mar 25, 2021, at 2:11 PM, Ricardo Parada wrote: >>=20 >> I=E2=80=99m gonna play with it but I see a couple of things to advance th= is. >>=20 >> One is to have an ignoresToManyNullify property that defaults to false so= that we don=E2=80=99t change the existing behavior.=20 >>=20 >> Then for us who don=E2=80=99t want to deal with null to-many relationship= s. We could set the property to true.=20 >>=20 >> Another option is to allow Skip to work on relationships.=20 >>=20 >> Thanks Aaron for the feedback.=20 >>=20 >> I think that code was written by David Avendasora.=20 >>=20 >> Ricardo >>=20 >>>=20 >>>> On Mar 25, 2021, at 1:35 PM, Aaron Rosenzweig wrote: >>>>=20 >>> =EF=BB=BFHi Ricardo, >>>=20 >>> I have similar feelings as you do that it=E2=80=99s not right as is.=20 >>>=20 >>> I believe the original author had in their mind =E2=80=9Ca perfect copy=E2= =80=9D - meaning that if there was something the copy got from awakeFromInse= rtion =E2=80=9Cfor free=E2=80=9D then it isn=E2=80=99t really a copy of the s= ource=E2=80=A6 so the author asked us to nullify.=20 >>>=20 >>> That said, there are issues with the current state of affairs: >>>=20 >>> 1) =E2=80=9CNullify=E2=80=9D for a toMany relationship should not set it= to =E2=80=9Cnull=E2=80=9D - it should at least set it to an empty array. Ha= ving it =E2=80=9Cnull=E2=80=9D can cause us gas because we are not expecting= toMany relationships to ever be null=E2=80=A6 they can be empty arrays but n= ot null.=20 >>>=20 >>> 2) =E2=80=9CSkip=E2=80=9D is valid for attributes, why not have it valid= for relationships? If we =E2=80=9Cskip=E2=80=9D then we can leave it alone.= For some reason, the author expressly didn=E2=80=99t want relationships to b= e skipped. It=E2=80=99s presently a syntax error.=20 >>>=20 >>> Cheers, >>> =E2=80=94 Aaron >>>=20 >>>> On Mar 25, 2021, at 1:25 PM, Ricardo Parada wrote: >>>>=20 >>>> I think ERXCopyable.java: 1286 should be changed to something like this= : >>>>=20 >>>> 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); >>>> } >>>>=20 >>>>=20 >>>>=20 >>>>=20 >>>>>> On Mar 25, 2021, at 1:02 PM, Ricardo Parada wrote: >>>>>>=20 >>>>> =EF=BB=BFHello everyone, >>>>>=20 >>>>> I like that in Wonder when you create an EO all the to-many relationsh= ips are initialized to an empty array because it means that I don=E2=80=99t h= ave to worry about null checking every time I access the to-many relationshi= p in order to avoid NullPointerExceptions.=20 >>>>>=20 >>>>> However, if I create my EO by copying an existing one using ERXCopyabl= e then any to-many relationships that have ERXCopyable.CopyType set to Nulli= fy will be set to null.=20 >>>>>=20 >>>>> Wouldn=E2=80=99t it be better to set them to an empty array? Or should= we have an Emptify option? >>>>>=20 >>>>> Thanks >>>>> Ricardo Parada >>>=20 >=20 --Apple-Mail-3A7D00F8-9375-4B54-BE78-4BC4C96EAF0C Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Aaron,

Got it. Thanks= for the heads up. 

Do you have any plans to s= ubmit a pull request for your fix? 

Ricardo Pa= rada 


Sent from my iPhone

On Apr 1, 2021, at 10:02 AM, Aaron R= osenzweig <webobjects-dev@wocommunity.org> wrote:

=
=EF=BB=BFRicardo (and friends) -= heads up. 

We modi= fied our local branch of WOnder to not null out the toMany relationship.&nbs= p;

We made an inno= cent mistake of setting an empty immutable NSArray. 

Even though most API methods return a= n interface of =E2=80=9CNSArray=E2=80=9D internally the data structure is mu= table. I believe the primary idea is that people shouldn=E2=80=99t add/remov= e from the array directly. That said, internally, you do need a mutable data= structure. 

= It must be an empty mutable NSMutableArray that you set. If you don=E2=80=99= t, when you try to add something to the toMany relationship it will fail.&nb= sp;


On M= ar 25, 2021, at 2:11 PM, Ricardo Parada <webobjects-dev@wocommunity.org> wrote:
I=E2=80=99m gonna play with it but I see a couple of th= ings to advance this.

On= e is to have an ignoresToManyNullify property that defaults to false so that= we don=E2=80=99t change the existing behavior. 
<= br class=3D"">
Then for us who don=E2=80=99t want to de= al 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

<= blockquote type=3D"cite" class=3D"">
On Mar 25, 2021, at 1:35 P= M, Aaron Rosenzweig <webobjects-dev@wocommunity.org> wrote:

=EF=BB=BFHi Ricardo,

<= /div>
I have similar feelings as you do that it=E2=80=99s not= right as is. 

I believe the original author had in their mind =E2=80=9Ca perfect copy=E2= =80=9D - meaning that if there was something the copy got from awakeFromInse= rtion =E2=80=9Cfor free=E2=80=9D then it isn=E2=80=99t really a copy of the s= ource=E2=80=A6 so the author asked us to nullify. 

That said, there are issues with the c= urrent state of affairs:

1) =E2=80=9CNullify=E2=80=9D for a toMany relationship should not set= it to =E2=80=9Cnull=E2=80=9D - it should at least set it to an empty array.= Having it =E2=80=9Cnull=E2=80=9D can cause us gas because we are not expect= ing toMany relationships to ever be null=E2=80=A6 they can be empty arrays b= ut not null. 

2) =E2=80=9CSkip=E2=80=9D is valid for attributes, why not have it valid fo= r relationships? If we =E2=80=9Cskip=E2=80=9D then we can leave it alone. Fo= r some reason, the author expressly didn=E2=80=99t want relationships to be s= kipped. It=E2=80=99s presently a syntax error. 
Cheers,
=E2=80=94 Aa= ron

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

I think ERXCopyable.java: 1286 should be cha= nged to something like this:

case NULLIFY:
    // Only set to-one relat= ionships to null. For to-many relationships we leave it alone with the empty= array setup during the creation of the EO
   = ; if (!relationship.isToMany()) {
      &= nbsp; destination.takeStoredValueForKey(null, relationshipName);
    }




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

=EF=BB=BFHello 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 th= at I don=E2=80=99t have to worry about null checking every time I access the= to-many relationship in order to avoid NullPointerExceptions. 

However, if I create my E= O by copying an existing one using ERXCopyable then any to-many relationship= s that have ERXCo= pyable.CopyType set to Nullify will be set to null. 

Wouldn=E2=80=99t it be bett= er to set them to an empty array? Or should we have an Emptify option?

= Thank= s
Ricardo Parada


= --Apple-Mail-3A7D00F8-9375-4B54-BE78-4BC4C96EAF0C--