Get relation information
775992
def relation_get(attribute=None, unit=None, rid=None):
    """"""
    _args = ['relation-get', '--format=json']
    if rid:
        _args.append('-r')
        _args.append(rid)
    _args.append(attribute or '-')
    if unit:
        _args.append(unit)
    try:
        return json.loads(subprocess.check_output(_args).decode('UTF-8'))
    except ValueError:
        return None
    except CalledProcessError as e:
        if e.returncode == 2:
            return None
        raise
1352524
def _parse_with_relations(self, relations):
        
        results = {}

        for relation in relations:
            if isinstance(relation, dict):
                for name, constraints in relation.items():
                    results = self._parse_nested_with(name, results)

                    results[name] = constraints

                continue
            else:
                name = relation
                constraints = self.__class__(self.get_query().new_query())

            results = self._parse_nested_with(name, results)

            results[name] = constraints

        return results
706618
def relations_of(self, target, include_object=False):
        '''  '''
        if include_object:
            _ = self._execute('''
                select relations.name, ob2.code from relations, objects as ob1, objects as ob2 where relations.src=ob1.id and ob2.id=relations.dst and ob1.code=?
            ''', (self.serialize(target),))
            for i in _:
                yield i[0], self.deserialize(i[1])
        else:

            _ = self._execute('''
                select distinct relations.name from relations, objects where relations.src=objects.id and objects.code=?
            ''', (self.serialize(target),))
            for i in _:
                yield i[0]
558831
def get_relations(self, cursor, table_name):
        
        cursor.execute(self._get_relations_query, {
            'schema': self.connection.schema_name,
            'table': table_name
        })
        relations = {}
        for row in cursor.fetchall():
            relations[row[1]] = (row[2], row[0])

        return relations
1224114
protected function guessRelation()
    {
        if ($this->relation) {
            return $this->relation;
        }

        return Str::camel(str_replace('_id', '', $this->name));
    }
1244107
def get(self, *args, **kwargs):
        """"""
        self.before_get(args, kwargs)

        relationship_field, model_relationship_field, related_type_, related_id_field = self._get_relationship_data()

        obj, data = self._data_layer.get_relationship(model_relationship_field,
                                                      related_type_,
                                                      related_id_field,
                                                      kwargs)

        result = {'links': {'self': request.path,
                            'related': self.schema._declared_fields[relationship_field].get_related_url(obj)},
                  'data': data}

        qs = QSManager(request.args, self.schema)
        if qs.include:
            schema = compute_schema(self.schema, dict(), qs, qs.include)

            serialized_obj = schema.dump(obj)
            result['included'] = serialized_obj.data.get('included', dict())

        final_result = self.after_get(result)

        return final_result
744105
function getRelated() {
  var relatedValues = getValue(this, 'see');
  if (relatedValues && relatedValues.trim().length > 0) {
    var relatedItems = relatedValues.split(',').map((relatedItem) => relatedItem.trim());
    return relatedItems.map((relatedItem) => '[' + relatedItem + '](#' + relatedItem + ')');
  } else {
    return [];
  }
}
1250856
public function getRelations ()
	{
		
		// Create new database tool

		$db	= new Db;
		
		$relations	= $db->getRelations ($this->get ('database'), $this->get ('table'));
		$namespace	= $this->getRootNamespace ();

		// Loop through constraints

		foreach ($relations as $constraint)
		{
			
			// If the attribute exists
			
			if (isset ($this->attributeCache[$constraint['attribute']]))
			{
				
				// Add relationship
				
				$this->attributeCache[$constraint['attribute']]['relation']	= $this->parser->convertToClassName ($constraint['table'], $namespace);
				
			}

		}
		
	}
451444
public function getRelationships()
    {
        if (empty(static::$relationHooks)) {
            $hooks = [];

            $rels = $this->getRelationshipsFromMethods(true);

            $this->getRelationshipsUnknownPolyMorph($rels, $hooks);

            $this->getRelationshipsKnownPolyMorph($rels, $hooks);

            $this->getRelationshipsHasOne($rels, $hooks);

            $this->getRelationshipsHasMany($rels, $hooks);

            static::$relationHooks = $hooks;
        }

        return static::$relationHooks;
    }
721826
def get_relations(self, rel_id=None, **kwargs):
        
        return self.get_elements(Relation, elem_id=rel_id, **kwargs)
924133
def get_from_relations(self, query,aliases):
        '''
        
        '''
        return [aliases[rel.get_name()] for rel in query.get_relations() if not rel.is_negated()]
979329
public function getRelations(&$query, $table)
    {
        $relations = [];
        $columns = [];
        /** @var Module $module */
        $module = $this->module;
        if (isset($module->tables[$table]['relations'])) {
            $relations = $module->tables[$table]['relations'];
        }
        foreach ($relations as $relation => $relationParams) {
            $query->join(
                $relationParams['type'],
                $relationParams['table'] . ' ' . $relationParams['alias'],
                $relationParams['on']
            );
            $columns[] = $relationParams['alias'] . '.' . $relationParams['representive_columns'] . ' ' . $relation;
        }

        return $columns;
    }
1037874
public function getRelations():array
    {
        $relations = array_unique(array_merge($this->getAvailableIncludes(), $this->relations));

        return array_filter($relations, function($relation) {
            return $relation !== '*';
        });
    }
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)
557601
public function getRelationships(): array
    {
        return array_column(
            array_filter(array_map(function ($includeKey, $settings) {
                return $settings['relation'] ? [$includeKey, $settings['relation']] : null;
            }, array_keys($this->getIncludeMap()), array_values($this->getIncludeMap()))),
            1, 0
        );
    }
1122742
def get_related_ids(self):
        
        related = self.get_related()

        full_key = related.get_qualified_key_name()

        return self.get_query().select(full_key).lists(related.get_key_name())
30023
public function getForeignItems(Saveable $class, $relation_details)
        {
            list ($query, $item_class, $item_column) = $this->generateForeignItemsQuery($class, $relation_details);
            if (!$item_class) {
                $items = array();
                $resultset = $this->rawSelect($query);
                if ($resultset) {
                    $column = "{$this->getB2DBName()}." . $relation_details['column'];
                    while ($row = $resultset->getNextRow()) {
                        $items[] = $row->get($column);
                    }
                }
                return $items;
            } elseif (!$relation_details['manytomany']) {
                return $this->select($query);
            } else {
                $resultset = $this->rawSelect($query);

                return $this->populateFromResultset($resultset, $item_class, $item_column, $item_column);
            }
        }