Hi Jesse,

Thanks for your help!
It worked exactly as you described.
Besides doing several other mistakes on the client side, I was including in the 
filter the relationship objects and its attributes rather than just 
filterWithAttributesAndToOneRelationships.

Best regards,
Catarina


A 23/02/2013, às 20:23, Jesse Tayler <[email protected]> escreveu:

> 
> ok, so you update an object -- by making a dictionary, then attaching two 
> separate dictionaries to that object with the only required attribute to be 
> the related object's primary key.
> 
> so, at least you must have two things correct.
> 
> 1. the update has to contain the keys to the related objects in a properly 
> related dictionary, etc.
> 2. the update filter has to include those relationships and attributes (which 
> it sounded like you have already got.)
> 
> the question is not if the objects exist in the database so much as does your 
> client already know the primary keys?
> 
> if you have the PKs, and your filter is ok, you should be able to do exactly 
> what you describe, as far as I can see.
> 
> you should be able to just write stuff out in the terminal using curl, e.g.:
> 
> curl -X PUT -d "{ post: { type:'Post', id:31210 }; author: { type:'User', 
> id:1 };   }" 
> http://localhost:5999/cgi-bin/WebObjects/ERRestApp.woa/ra/BookmarkPost.json
> 
> that user record has to exist in the database already, so you'd have to 
> already know this on your client.
> 
> this is why often, you have additional steps where you have to fetch or 
> create first, then update.
> 
> hope that helps
> 
> 
> On Feb 23, 2013, at 2:36 PM, Catarina Simões <[email protected]> wrote:
> 
>> Hi Jesse and all,
>> 
>> First of all I'm using the method update from ERXRouteController to update 
>> the object.
>> I was wrong when I thought the objects in the relationships (object1 and 
>> object2 in my example) were being created by this update method. They are 
>> not created but the previous objects in the relationships are being updated 
>> with object1 and object2 information.
>> 
>> All I want is just to replace the existing objects in the relationships by 
>> these ones (that already exist in the database).
>> Can ERXRouteController update with the right filter do that or do I have to 
>> handle the request myself and update the object and replace the 
>> relationships by the new ones? In the first case which filter can be used?
>> 
>> Thanks in advance.
>> Best regards,
>> Catarina
>> 
>> 
>> A 18/02/2013, às 17:23, Jesse Tayler <[email protected]> escreveu:
>> 
>>> 
>>> Whoops.
>>> 
>>> Update, yes. 
>>> 
>>> Create? No.
>>> 
>>> You need to create objects separately and create each related object one at 
>>> a time - not like transaction w/rollback
>>> 
>>> Make sense?
>>> 
>>> On Feb 18, 2013, at 12:14 PM, Jesse Tayler <[email protected]> wrote:
>>> 
>>>> yes.
>>>> 
>>>> 
>>>> 
>>>> 
>>>> On Feb 18, 2013, at 12:06 PM, Catarina Simões <[email protected]> 
>>>> wrote:
>>>> 
>>>>> Hi all,
>>>>> 
>>>>> I'm using RestKit and ERRest to access services provided from a web app 
>>>>> in WO to a OS X app.
>>>>> I'm doing a PUT to update an object that has several one-to-one 
>>>>> relationships. The request sent by RestKit is something like this:
>>>>> {
>>>>> "attrib1": "attrib1 value",
>>>>> "attrib2": "attrib2 value",
>>>>> "object1": {
>>>>>    "id": 2,
>>>>>    "name": "some name"
>>>>> },
>>>>> "id": 1,
>>>>> "object2": {
>>>>>    "id": 1,
>>>>>    "name": "some other name",
>>>>>    "description": "some description"
>>>>> }
>>>>> }
>>>>> 
>>>>> On the WO side the object attributes are updated but also both object1 
>>>>> and object2 are created rather than just updating the relationship to 
>>>>> those objects.
>>>>> The filter I'm using in the update includes all the attributes to the 
>>>>> object being updated and also the 2 relationship objects and 
>>>>> corresponding attributes.
>>>>> 
>>>>> Shouldn't the WO side recognize the objects in the relationships, fetch 
>>>>> them and traverse the relationships and update the already existing 
>>>>> objects?
>>>>> 
>>>>> Thanks in advance.
>>>>> Best regards,
>>>>> Catarina
>>>>> _______________________________________________
>>>>> Do not post admin requests to the list. They will be ignored.
>>>>> Webobjects-dev mailing list      ([email protected])
>>>>> Help/Unsubscribe/Update your Subscription:
>>>>> https://lists.apple.com/mailman/options/webobjects-dev/jtayler%40oeinc.com
>>>>> 
>>>>> This email sent to [email protected]
>>>> 
>>>> 
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> Webobjects-dev mailing list      ([email protected])
>>>> Help/Unsubscribe/Update your Subscription:
>>>> https://lists.apple.com/mailman/options/webobjects-dev/jtayler%40oeinc.com
>>>> 
>>>> This email sent to [email protected]
>> 
> 

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to