Problem with attributes with "id" in their name

1 view
Skip to first unread message

echamussy

unread,
Dec 1, 2009, 8:25:42 PM12/1/09
to restfulx-framework
Hello everyone,
I have a model that contains an integer attribute called "tweet_id".
When I try to get data from the database it always comes as zero. I
started diggin in the restfulx code and discovered that when the xml
is being unmarshalled there is an if statement that looks for "_id" in
the name of the attribute:

XMLSerializer.as - Line 181
...
if (targetName.search(/.+\_id$/) == -1 && element.text().length
() == 1) {
defaultValue = RxUtils.cast(element.@type, element.toString
());
}

....

Because the name of the attribute containds '_id' then the value is
never set. I don't have a Model called Tweet so there is no
relationship to be found with other models. I just need to bring the
tweet_id value to my model but it gets lost when unmarshalling.

Any suggestions on how to avoid this?

Thanks !!
Regards,

Enrique

Dima Berastau

unread,
Dec 1, 2009, 9:05:05 PM12/1/09
to restfulx-...@googlegroups.com
Hi Enrique,

Yes, don't call your model attributes *_id or *_type, these are reserved for relationships and inheritance (borrowed from Rails).

cheers,
Dima
> --
>
> You received this message because you are subscribed to the Google Groups "restfulx-framework" group.
> To post to this group, send email to restfulx-...@googlegroups.com.
> To unsubscribe from this group, send email to restfulx-framew...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/restfulx-framework?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages