Hi all, We've found out this is a bug. The ERRestRequestNode ignores the type field when creating objects for toOne and toMany relationships. We're going to create a pull request to fix this problem soon.
BTW, is there a way to verify we didn't introduce a bug in ERRest while trying to fix another one? Cheers, Henrique Sent from my iPhone > On 02/12/2013, at 22:41, Elizio Marcelino <[email protected]> wrote: > > Hi, > > > I'm having trouble working with ERRest and EO with inheritance. > > I have the following structure in my EO Model. > > Order > - id > - quantity > - NSArray<AbstractPayment> payments > > > AbstractPayment > - id - autoIncrement > - status > > CreditCardPayment extends AbstractPayment > - amount > - installments > > DebitCardPayment extends AbstractPayment > - number > - holder > > In my REST API, in my class OrderController doing well CreateAction: > > public WOActionResults createAction() throws Throwable { > Order order = (Order)create(entityName(), filterWithAllRecursive()); > } > > I am making the following call with rest: > > { > "status":"created", > "payments": [ > { > "type": "CreditCardPayment" > "amount":100 > "instalments": 1 > } > ] > } > > If you notice my class CreditCardPayment extends AbstractPayment, and when I > send my request to the list of payment am having the following error: > > <com.webobjects.foundation.NSKeyValueCoding$UnknownKeyException message > '<AbstractPayment 0x7656e376> takeValueForKey(): attempt to assign value to > unknown key: 'amount'. > > This class does not have an instance variable of the name amount or _amount, > nor a method of the name setAmount or _setAmount' object '<AbstractPayment > pk:"null">' key 'amount'> > > > > I believe when it is done trying to convert JSON to the Order object it is > trying to convert the List of payment for AbstractPayment and not to > CreditCardPayment. > > How can we show to create what should be done by CreditCardPayment > DebitCartPayment or not by AbstractPayment? > > > > Thank you. > Elizio > > _______________________________________________ > 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/hprange%40gmail.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]
