fix to Model::getForeignObjectsQuery