Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

RESTful Server bug with many_many relations


Go to End


3 Posts   2718 Views

Avatar
motoservo

Community Member, 27 Posts

3 July 2009 at 10:21pm

On the wiki it explains that I should be able to use a restful operation in the form:

"GET /api/v1/(ClassName)/(ID)/(Relation) - get all of the records linked to this database record by the given relation".

but this operation won't execute if the relation is a many_many. It seems to work okay as a has_one or a has_many though.

Does anyone have a suggestion? I'm using a daily build of trunk from just a few days ago.

Avatar
motoservo

Community Member, 27 Posts

6 July 2009 at 2:40pm

UPDATE

The reason for this bug is an error on line 521 of RestfulServer.php. The
method called getObjectRelationQuery() should return this line:

return $this->getSearchQuery($relationClass[1], $params, $sort, $limit,
$query);

instead of:

return $this->getSearchQuery($relationClass, $params, $sort, $limit,
$query);

Avatar
Ingo

Forum Moderator, 801 Posts

8 July 2009 at 8:29pm

Thanks for tracking this down motoservo! So much for consistent API return values... ;)
I've fixed this in trunk with http://open.silverstripe.com/changeset/81346