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-ztdg10061801.me.com ([17.58.63.170] verified) by post.selbstdenker.com (CommuniGate Pro SMTP 6.3.3) with ESMTPS id 25700620 for webobjects-dev@wocommunity.org; Sat, 10 Apr 2021 05:13:47 +0200 Received-SPF: pass receiver=post.selbstdenker.com; client-ip=17.58.63.170; envelope-from=rparada@mac.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=1a1hai; t=1618024405; bh=qAmRVffkULPsOqqC6jmNmZT407NbGn+SGf80dsMmL3Q=; h=Content-Type:From:Mime-Version:Subject:Date:Message-Id:To; b=RiPOBgyjvH4/gJA3sjUjkWJ3A7N3XM8xh+9r4fDKOtRcFXYqiT5uMV9Yl5Mpt4aoA SIdU/ynDYN9aytvbOis+c6OB36RzJ++NBT8B+5/YIx2jSJyV+9rda3yJn34ibVmY+U 4tHSi7IB86tPNOK9GcvcuQqSN7kkWyWTDUiS/k4Ni7qBk+lZq0jk9lPblWTGjb95i6 W1WW7vMVsdK942mbGp4piaNYrhIcpLKWULOAF3FAsp30LJwvgmysh66h1n+Wit3EHP 1rlq/LeN5BJNMjxBYhIgxH5GQbT9d+tZ+etQ8TATyyzjoWi/pNChjBZd93SDvgVGZF QC5dejbp6SWbQ== Received: from [10.0.0.34] (c-174-61-52-234.hsd1.fl.comcast.net [174.61.52.234]) by st43p00im-ztdg10061801.me.com (Postfix) with ESMTPSA id 853998C037F for ; Sat, 10 Apr 2021 03:13:25 +0000 (UTC) Content-Type: multipart/alternative; boundary=Apple-Mail-AC843A3D-94B2-48CE-AABE-84003D59D3BF 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 23:13:24 -0400 Message-Id: References: In-Reply-To: To: WebObjects & WOnder Development X-Mailer: iPhone Mail (18D70) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-04-10_01:2021-04-09,2021-04-10 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2009150000 definitions=main-2104100023 --Apple-Mail-AC843A3D-94B2-48CE-AABE-84003D59D3BF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Awesome, thank you Aaron.=20 Ricardo > On Apr 9, 2021, at 8:20 PM, Aaron Rosenzweig wrote: >=20 > =EF=BB=BFHi Ricardo,=20 >=20 > My pleasure, here=E2=80=99s the pull request: https://github.com/wocommuni= ty/wonder/pull/945 >=20 > Speaking of toMany relationships=E2=80=A6 >=20 > Why did the database administrator leave his wife?=20 > She had one-to-many relationships. >=20 >> On Apr 9, 2021, at 6:32 PM, Ricardo Parada wrote: >>=20 >> Hi Aaron, >>=20 >> Got it. Thanks for the heads up.=20 >>=20 >> Do you have any plans to submit a pull request for your fix?=20 >>=20 >> Ricardo Parada=20 >>=20 >>=20 >> Sent from my iPhone >>=20 >>>> 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 relati= onship.=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= =99t, 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 t= his. >>>>=20 >>>> One is to have an ignoresToManyNullify property that defaults to false s= o 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 relationsh= ips. 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 cop= y=E2=80=9D - meaning that if there was something the copy got from awakeFromI= nsertion =E2=80=9Cfor free=E2=80=9D then it isn=E2=80=99t really a copy of t= he source=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 i= t to =E2=80=9Cnull=E2=80=9D - it should at least set it to an empty array. H= aving it =E2=80=9Cnull=E2=80=9D can cause us gas because we are not expectin= g toMany relationships to ever be null=E2=80=A6 they can be empty arrays but= not null.=20 >>>>>=20 >>>>> 2) =E2=80=9CSkip=E2=80=9D is valid for attributes, why not have it val= id for relationships? If we =E2=80=9Cskip=E2=80=9D then we can leave it alon= e. For some reason, the author expressly didn=E2=80=99t want relationships t= o be 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 th= is: >>>>>>=20 >>>>>> case NULLIFY: >>>>>> // Only set to-one relationships to null. For to-many relationshi= ps we leave it alone with the empty array setup during the creation of the E= O >>>>>> 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 relation= ships are initialized to an empty array because it means that I don=E2=80=99= t have to worry about null checking every time I access the to-many relation= ship in order to avoid NullPointerExceptions.=20 >>>>>>>=20 >>>>>>> However, if I create my EO by copying an existing one using ERXCopya= ble then any to-many relationships that have ERXCopyable.CopyType set to Nul= lify will be set to null.=20 >>>>>>>=20 >>>>>>> Wouldn=E2=80=99t it be better to set them to an empty array? Or shou= ld we have an Emptify option? >>>>>>>=20 >>>>>>> Thanks >>>>>>> Ricardo Parada >>>>>=20 >>>=20 >=20 --Apple-Mail-AC843A3D-94B2-48CE-AABE-84003D59D3BF Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Awesome, thank you Aaron. 

Ricardo

On A= pr 9, 2021, at 8:20 PM, Aaron Rosenzweig <webobjects-dev@wocommunity.org&= gt; wrote:

=EF=BB=BFHi Ricardo, 

My pleasure, here=E2=80=99s the pull request: https://github.com/wocommuni= ty/wonder/pull/945

Speaking of toMany relationships=E2=80=A6

Why did the database administrator leave his wife?&= nbsp;
She had one-to-many relationships.

On A= pr 9, 2021, at 6:32 PM, Ricardo Parada <webobjects-dev@wocommunity.org> wrote:
Hi Aaron,

Got it. Thanks for the heads up. 

Do you have any plans to submit a pull request for y= our fix? 

Ric= ardo Parada 


Sent from my iPhone
On Apr 1, 2021, at 10:02 A= M, Aaron Rosenzweig <webobjects-dev@wocommunity.org> wrote:

=EF=BB=BFRicardo (and friends) - heads up. 
We modified our local branc= h of WOnder to not null out the toMany relationship. 

We made an innocent mistake of setti= ng an empty immutable NSArray. 

Even though most API methods return an interface of =E2=80= =9CNSArray=E2=80=9D internally the data structure is mutable. I believe the p= rimary idea is that people shouldn=E2=80=99t add/remove from the array direc= tly. That said, internally, you do need a mutable data structure. 

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


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

I=E2=80=99m gonna play with it but I see a c= ouple of things to advance this.

One is to have an ignoresToManyNullify property that defaults to fa= lse so that we don=E2=80=99t change the existing behavior. 

Then for us who don=E2=80=99t= want to deal with null to-many relationships. We could set the property to t= rue. 

Another= option is to allow Skip to work on relationships. 

Thanks Aaron for the feedback. <= /div>

I think that code w= as written by David Avendasora. 

Ricardo


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

=EF=BB=BFHi Ricardo,

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 awake= FromInsertion =E2=80=9Cfor free=E2=80=9D then it isn=E2=80=99t really a copy= of the source=E2=80=A6 so the author asked us to nullify. 

That said, there are issues w= ith the current state of affairs:

=
1) =E2=80=9CNullify=E2=80=9D for a toMany relationship shoul= d not set it to =E2=80=9Cnull=E2=80=9D - it should at least set it to an emp= ty array. Having it =E2=80=9Cnull=E2=80=9D can cause us gas because we are n= ot expecting toMany relationships to ever be null=E2=80=A6 they can be empty= arrays but not null. 

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 a= lone. For some reason, the author expressly didn=E2=80=99t want relationship= s to be skipped. It=E2=80=99s presently a syntax error. 

Cheers,
=E2= =80=94 Aaron

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-AC843A3D-94B2-48CE-AABE-84003D59D3BF--