Updated get_with() to pass the intended ordering value to get_related().
Issue
I found that, with a 'many' relationship, we didn't seem to have control over the ordering of the related records.
Looking at the code, I could see that $join_method_order
was being established in get_with()
for each related model, but then apparently not used.
What I did
- Updated
get_with()
to pass the intended ordering value toget_related()
.
Implications
None
Setup
None
How to test
- Code review
- Test with any code that uses a 'many' related model, and add an ordering param to the definition of that relationship, e.g. the second one in this list
- Change between ASC and DESC to confirm that this change is effective
public static $related_models = array (
'database/countries_model' => array('country_details', 'country_id', 'id', 'one'), // Full details of the country to which this gallery belongs.
'database/gallery_images_model' => array('images', 'id', 'gallery_id', 'many', 'id ASC') // All the images linked to this gallery.
);
Edited by Robert Sinton