Eager load the relationship of the models.

        :param models:
        :type models: list

        :return: The models
        :rtype: list
333018
def eager_load_relations(self, models):
        
        for name, constraints in self._eager_load.items():
            if name.find('.') == -1:
                models = self._load_relation(models, name, constraints)

        return models
1201293
def load(self, data):
        
        objs = {}
        for mapper in self.entities:
            objs[mapper.name] = mapper.load(self.loader, data)

        for mapper in self.relations:
            objs[mapper.name] = mapper.load(self.loader, data, objs)
381332
def get_models(self):
        
        try:
            rels = self.rels_ext.content
        except RequestFailed:
            # if rels-ext can't be retrieved, confirm this object does not have a RELS-EXT
            # (in which case, it does not have any content models)
            if "RELS-EXT" not in self.ds_list.keys():
                return []
            else:
                raise

        return list(rels.objects(self.uriref, modelns.hasModel))
744793
def _get_models(self, app):
        
        try:
            app_models = app.get_models()
            appmods = []
            for model in app_models:
                appmods.append(model)
        except Exception as e:
            self.err(e)
            return
        return appmods
494351
def import_models(module):
    
    try:
        module = importlib.import_module('{0}.models'.format(module))
    except ImportError:
        return []
    else:
        clsmembers = inspect.getmembers(module, lambda member: inspect.isclass(member) and member.__module__ == module.__name__)
        return [kls for name, kls in clsmembers]
1302164
def get_eager(self):
        
        for type in self._dictionary.keys():
            self._match_to_morph_parents(type, self._get_results_by_type(type))

        return self._models
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)
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)
1168957
def relations(cls):
        
        return [c.key for c in cls.__mapper__.iterate_properties
                if isinstance(c, RelationshipProperty)]
634754
def related_objects(self, related, objs):
        
        from versions.models import Versionable

        related_model = related.related_model
        if issubclass(related_model, Versionable):
            qs = related_model.objects.current
        else:
            qs = related_model._base_manager.all()
        return qs.using(self.using).filter(
            **{"%s__in" % related.field.name: objs}
        )
375600
def upsert_entity_relationships(self, queryset, entity_relationships):
        

        # Select the relationships for update
        if entity_relationships:
            list(queryset.select_for_update().values_list(
                'id',
                flat=True
            ))

        # Sync the relationships
        return manager_utils.sync(
            queryset=queryset,
            model_objs=entity_relationships,
            unique_fields=['sub_entity_id', 'super_entity_id'],
            update_fields=[],
            return_upserts=True
        )
908523
def columns(self, model=None):
        
        for query in self.__queries:
            for column in query.columns(model=model):
                yield column
1209406
def views(model: "Model") -> list:
    
    if not isinstance(model, Model):
        raise TypeError("Expected a Model, not %r." % model)
    return model._model_views[:]
379034
def get_queryset(self):
        
        if self.relation_names is None:
            raise ImproperlyConfigured(
                "'%s' must define 'relation_names'" %
                self.__class__.__name__)
        if not isinstance(self.relation_names, (tuple, list)):
            raise ImproperlyConfigured(
                "%s's relation_names property must be a tuple or list." %
                self.__class__.__name__)
        return super(PrefetchRelatedMixin, self
                     ).get_queryset().prefetch_related(*self.relation_names)
449688
def models(self):
        """"""
        Model_ = self.app.config['PEEWEE_MODELS_CLASS']
        ignore = self.app.config['PEEWEE_MODELS_IGNORE']

        models = []
        if Model_ is not Model:
            try:
                mod = import_module(self.app.config['PEEWEE_MODELS_MODULE'])
                for model in dir(mod):
                    models = getattr(mod, model)
                    if not isinstance(model, pw.Model):
                        continue
                    models.append(models)
            except ImportError:
                return models
        elif isinstance(Model_, BaseSignalModel):
            models = BaseSignalModel.models

        return [m for m in models if m._meta.name not in ignore]
83054
def _find_references(model_name, references=None):
    
    references = references or []
    references.append(model_name)

    ref = MODELS[model_name].get('reference')
    if ref is not None:
        _find_references(ref, references)

    parent_models = [m for m in references]
    parent_models.reverse()

    return parent_models
424489
def get_models(self, columns=None):
        
        results = self._query.get(columns)

        connection = self._model.get_connection_name()

        return self._model.hydrate(results, connection).all()