Eagerly load the relationship on a set of models.

        :rtype: list
192650
def _load_relation(self, models, name, constraints):
        
        relation = self.get_relation(name)

        relation.add_eager_constraints(models)

        if callable(constraints):
            constraints(relation)
        else:
            relation.merge_query(constraints)

        models = relation.init_relation(models, name)

        results = relation.get_eager()

        return relation.match(models, results, name)
199938
def _list_model(self, model_cls: Type[X]) -> List[X]:
        """"""
        return self.session.query(model_cls).all()
1038405
def _get_fields_for_model(model):
    
    fields = []
    for name in model._sa_class_manager:
        prop = getattr(model, name)
        if isinstance(prop.property, RelationshipProperty):
            for pk in prop.property.mapper.primary_key:
                fields.append('{0}.{1}'.format(name, pk.name))
        else:
            fields.append(name)
    return tuple(fields)
1057332
def add_eager_constraints(self, models):
        
        super(MorphOneOrMany, self).add_eager_constraints(models)

        self._query.where(self._morph_type, self._morph_class)
971678
def cache_relationships(self, cache_super=True, cache_sub=True):
        
        return self.get_queryset().cache_relationships(cache_super=cache_super, cache_sub=cache_sub)
177824
def add_eager_constraints(self, models):
        
        self._models = Collection.make(models)
        self._build_dictionary(models)
1050619
def reload(self):
        
        new_model = self.collection.get(self.id)
        self.attrs = new_model.attrs
1118861
private Pair<Map<String, Model>, Map<String, Set<String>>> fetchModels() {
    Map<String, Model> all_models = null;
    Map<String, Set<String>> all_models_cols = null;

    if (this.find_compatible_models) {
      // caches for this request
      all_models = (new Models()).fetchAll();
      all_models_cols = new TreeMap<String, Set<String>>();

      for (Map.Entry<String, Model> entry : all_models.entrySet()) {
        all_models_cols.put(entry.getKey(), new TreeSet<String>(Arrays.asList(entry.getValue()._names)));
      }
    }
    return new Pair<Map<String, Model>, Map<String, Set<String>>>(all_models, all_models_cols);
  }
1084613
def find_all_models(models):
    
    for model in models:
        yield model
        # noinspection PyProtectedMember
        for parent in model._meta.parents.keys():
            for parent_model in find_all_models((parent,)):
                yield parent_model
181928
def links(self):
        
        link_dict = {'self': self.resource_uri()}
        for relationship in inspect(  # pylint: disable=maybe-no-member
                self.__class__).relationships:
            if 'collection' not in relationship.key:
                instance = getattr(self, relationship.key)
                if instance:
                    link_dict[str(relationship.key)] = instance.resource_uri()
        return link_dict
914219
def _load_scoped_variable_models(self):
        
        self.scoped_variables = []
        for scoped_variable in self.state.scoped_variables.values():
            self._add_model(self.scoped_variables, scoped_variable, ScopedVariableModel)
908523
def columns(self, model=None):
        
        for query in self.__queries:
            for column in query.columns(model=model):
                yield column
527101
def save_many(self, models, joinings=None):
        
        if joinings is None:
            joinings = {}

        for key, model in enumerate(models):
            self.save(model, joinings.get(key), False)

        self.touch_if_touching()

        return models
133212
def match(self, models, results, relation):
        
        foreign = self._foreign_key

        other = self._other_key

        dictionary = {}

        for result in results:
            dictionary[result.get_attribute(other)] = result

        for model in models:
            value = model.get_attribute(foreign)

            if value in dictionary:
                model.set_relation(relation, dictionary[value])

        return models
229438
def models(self):
        '''
        
        '''
        model_dict = self._build_all_dependencies()
        while True:
            model = self._get_model_without_dependencies(model_dict)
            if not model:
                break
            yield (model, self._models().get(model))
716070
def _nested_relations(self, relation):
        
        nested = {}

        for name, constraints in self._eager_load.items():
            if self._is_nested(name, relation):
                nested[name[len(relation + ".") :]] = constraints

        return nested
557596
def _init_relationships(self, relationships_arg):
        """"""
        if relationships_arg:
            relationships_all = self._get_all_relationships()
            if relationships_arg is True:
                return relationships_all
            else:
                return relationships_all.intersection(relationships_arg)
        return set()