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: "Aaron Rosenzweig" Received: from mail-qt1-f177.google.com ([209.85.160.177] verified) by selbstdenker.ag (CommuniGate Pro SMTP 6.3.3) with ESMTPS id 25659189 for webobjects-dev@wocommunity.org; Thu, 01 Apr 2021 16:02:09 +0200 Received-SPF: none receiver=post.selbstdenker.com; client-ip=209.85.160.177; envelope-from=recurve@cocoanutstech.com Received: by mail-qt1-f177.google.com with SMTP id c6so1528287qtc.1 for ; Thu, 01 Apr 2021 07:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chatnbike.com; s=chatnbike; h=from:message-id:mime-version:date:subject:in-reply-to:to:references; bh=HvRa1fkjdv+m+XOGpo1W1cOz5S/QxFRHHtzsjJP7pgY=; b=W80W2UWin5Ao3/o5vzcFwFeL5Ed2QISrfrKoUqARtomRDoOc2pi97KrfFhVSTL8sbf K2zNIAzhnzbdTmx1h+VZcj/9jZWzFSy2lYwrLvTk+dbFGRcOwdSLOcs2ElEYdwWBzutc 7Ni+WPW1s/Hr850ZSV8rq0+INRW+VBVOmvErk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:date:subject :in-reply-to:to:references; bh=HvRa1fkjdv+m+XOGpo1W1cOz5S/QxFRHHtzsjJP7pgY=; b=LIz2iHQKHNauBmJtw61qK1Uedii51afh1qRGTuGAJRX31Ox43S2MRsP1nu06K8SR4X MBY3hgPoqQUVcrC9IZUnvETNnKDoSdG5io+vq/UjQy9xWtwIfXq2lVzhoC8Ko/H9xqXg apYjpkyIIhrmhtDXwbBceT3vuRJBWdWUuy41TtjM4B1tAss1jq+YlwNSqQR4dTXPCvmu P2jLzE++tUSvhxXfz/aDPOSGGVqxO6jWz7m8J30JBW0/NEhLtn+48PHe5zUuaOtI9CNh oqMQhQDlljQuOR4fBa3Ktc0J2X7K9ePbQ3i+vyu3WBLPYdV1AnGGi1MRxqvM/Na2IAKb Jxwg== X-Gm-Message-State: AOAM531BuqftGN8cYkJHiUM/5MLIJN2hWDGEis6bMUXDM+XZFOUxLIfY 6kP9KHBiOwy8llr5X6JHwWTcx2DFm+fUKqaOVPU= X-Google-Smtp-Source: ABdhPJyflAs/e6sOFDgjo2rqcCcRWT9sdRfyj+8LATufi/DJAGcoaRuf7z+MEiTBkanIsnm9QnQbPQ== X-Received: by 2002:ac8:4816:: with SMTP id g22mr7364461qtq.187.1617285707194; Thu, 01 Apr 2021 07:01:47 -0700 (PDT) Return-Path: Received: from mac-pro.lan (pool-173-79-35-204.washdc.fios.verizon.net. [173.79.35.204]) by smtp.gmail.com with ESMTPSA id x10sm3327986qtw.17.2021.04.01.07.01.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Apr 2021 07:01:45 -0700 (PDT) Message-Id: <85E03B35-48A3-4245-A108-03FD2C4B4AB1@chatnbike.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_DEE380BE-375E-45C7-8522-FF9C8036DF51" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Date: Thu, 1 Apr 2021 10:01:54 -0400 Subject: Re: [WO-DEV] ERXCopyable.CopyType = Nullify on to-many relationship should empty instead In-Reply-To: To: WebObjects & WOnder Development References: X-Mailer: Apple Mail (2.3654.60.0.2.21) --Apple-Mail=_DEE380BE-375E-45C7-8522-FF9C8036DF51 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Ricardo (and friends) - heads up.=20 We modified our local branch of WOnder to not null out the toMany = relationship.=20 We made an innocent mistake of setting an empty immutable NSArray.=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 that people shouldn=E2=80=99t add/remove from the array directly. = That said, internally, you do need a mutable data structure.=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 > 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 = this. >=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 = relationships. 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 = awakeFromInsertion =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.=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. Having 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 not 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 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 = 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 = relationships are initialized to an empty array because it means that I = don=E2=80=99t have to worry about null checking every time I access the = to-many relationship in order to avoid NullPointerExceptions.=20 >>>>=20 >>>> 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.=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 --Apple-Mail=_DEE380BE-375E-45C7-8522-FF9C8036DF51 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Ricardo (and friends) - heads up. 

We modified our local branch of WOnder = to not null out the toMany relationship. 

We made an innocent mistake of setting = 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 primary idea is that people shouldn=E2=80=99t = add/remove 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=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> wrote:

I=E2=80=99m 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=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 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:
=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 awakeFromInsertion =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 with the = current 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 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 alone. For some reason, the author expressly = didn=E2=80=99t want relationships 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> 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:
=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 that 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 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=E2=80=99t it be = better to set them to an empty array? Or should we have an Emptify = option?

Thanks
Ricardo = Parada
<= /div>
<= br class=3D"">
= --Apple-Mail=_DEE380BE-375E-45C7-8522-FF9C8036DF51--