if single relationship is requested, perform eager loading. For example, helps to
optimize loading uni-directional associations during inclusions (used the default
relationship repositories)
325823
private boolean optimizeForInclusion(QuerySpec querySpec) {
        ResourceField idField = getIdField();
        return querySpec.getIncludedRelations().size() == 1 &&
                querySpec.getIncludedFields().size() == 1
                && idField.getUnderlyingName().equals(querySpec.getIncludedFields().get(0).getPath().toString());
    }
162821
protected function loadHasOne(
        Collection $relations,
        HasOneOrMany $relationClass,
        Model $relationModel,
        Model $model,
        Builder $query,
        $direction
    ) {
        $this->loadHasOneOrMany($relations, $relationClass, $relationModel, $model, $query, $direction);
    }
1322012
def add_eager_constraints(self, models):
        
        key = "%s.%s" % (self._related.get_table(), self._other_key)

        self._query.where_in(key, self._get_eager_model_keys(models))
1373735
def fetch_related_resource_id_tree(relationship)
      relationship_name = relationship.name.to_sym
      @related_resource_id_trees[relationship_name] ||= RelatedResourceIdTree.new(relationship, self)
    end
322704
protected function loadBelongsTo(
        Collection $relations,
        BelongsTo $relationClass,
        Model $relationModel,
        Model $model,
        Builder $query,
        $direction
    ) {
        $foreignKey = $relationClass->getOwnerKey();
        $ownerKey = $relationClass->getForeignKey();

        $ownerTable = $model->getTable();
        $foreignTable = $relationModel->getTable();

        $ownerColumn = implode('.', [$ownerTable, $ownerKey]);
        $foreignColumn = implode('.', [$foreignTable, $foreignKey]);
        $sortedColumnRaw = '`'.$foreignTable.'`.`'.$relations->last().'`';
        $sortedColumnAlias = implode('__', [$foreignTable, $relations->last()]);

        $this->sortedColumnAlias = $sortedColumnAlias;

        $query
            ->addSelect([DB::raw($sortedColumnRaw.' AS '.$sortedColumnAlias)])
            ->join($foreignTable, $foreignColumn, '=', $ownerColumn, 'left');
    }
169510
def add_eager_constraints(self, models):
        
        table = self._parent.get_table()

        self._query.where_in("%s.%s" % (table, self._first_key), self.get_keys(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)
737675
public function addConstraints()
    {
        if (static::$hasConstraints) {
            // For belongs to relationships, which are essentially the inverse of has one
            // or has many relationships, we need to actually query on the primary key
            // of the related models matching on the foreign key that's on a parent.
            $foreign_keyValue = $this->parent->getAttribute($this->foreign_key);
            $this->query->where($this->local_key, '=', $foreign_keyValue);
        }
    }
648449
def fetchmany(self, *args, **kwargs):
        

        if not self.single_cursor_mode:
            raise S3MError("Calling Connection.fetchmany() while not in single cursor mode")

        return self._cursor.fetchmany(*args, **kwargs)
1290127
function(sideloaded) {
        var store = get(this, 'store');
        var models = {};
        var serializer = this;

        sideloaded.forEach(function(link) {
          var type = link.type;
          if (link.relationships) {
            serializer.extractRelationships(link.relationships, link);
          }
          delete link.type;
          if (!models[type]) {
            models[type] = [];
          }
          models[type].push(link);
        });

        this.pushPayload(store, models);
      }
1368344
def load_associated_records
      array = @owner.class.session.connection.get_relationships(@owner.class._module.name, @owner.id, @association.to_s)
      @loaded = true
      # we use original to track the state of the collection at start
      @collection = Array.wrap(array).dup
      @original   = Array.wrap(array).freeze
    end
1073247
function(store, snapshot, url, relationship) {
        var belongsTo = snapshot.belongsTo(relationship.key);
        var belongsToLoaded = belongsTo && !belongsTo.record.get('_internalModel.currentState.isEmpty');

        if(belongsToLoaded) {
          return;
        }

        return this._super(store, snapshot, url, relationship);
      }
249388
def with_(self, *relations):
        
        if not relations:
            return self

        eagers = self._parse_with_relations(list(relations))

        self._eager_load.update(eagers)

        return self
1224391
def match(self, models, results, relation):
        
        dictionary = self._build_dictionary(results)

        for model in models:
            key = model.get_key()

            if key in dictionary:
                collection = self._related.new_collection(dictionary[key])

                model.set_relation(relation, collection)

        return models
256329
protected static function _relationsToLoad() {
		try {
			if (!$connection = static::connection()) {
				return;
			}
		} catch (ConfigException $e) {
			return;
		}

		if (!$connection::enabled('relationships')) {
			return;
		}

		$self = static::_object();

		foreach ($self->_relationTypes as $type) {
			$self->$type = Set::normalize($self->$type);
			foreach ($self->$type as $name => $config) {
				$self->_relationsToLoad[$name] = $type;
				$fieldName = $self->_relationFieldName($type, $name);
				$self->_relationFieldNames[$fieldName] = $name;
			}
		}
	}
797977
def cache_relationships(self, cache_super=True, cache_sub=True):
        
        relationships_to_cache = compress(
            ['super_relationships__super_entity', 'sub_relationships__sub_entity'], [cache_super, cache_sub])
        return self.prefetch_related(*relationships_to_cache)
121446
protected function parseInclude()
    {
        $eagerLoadingKeys = explode(',', $this->parameters['include']);

        foreach ($eagerLoadingKeys as $eagerLoadingKey) {
            $this->query->load(array_diff($this->modelInformation->getRelations(), $eagerLoadingKey));
        }
    }