Translate a relation node into SQLQuery.
        :param node: a treebrd node
        :return: a SQLQuery object for the tree rooted at node
551310
def relation(self, node):
        
        return self.query(select_block=str(node.attributes),
                          from_block=node.name)
252974
def get_node_index(self, node):
        

        if node == self.__root_node:
            return QModelIndex()
        else:
            row = node.row()
            return self.createIndex(row, 0, node) if row is not None else QModelIndex()
1262189
def to_sql(self):
        
        return self._sql_query_skeleton.format(
            prefix=self.prefix, select=self.select_block,
            relation=self.from_block, conditions=self.where_block)
943241
def _create_query(node, context):
    
    visited_nodes = [node]
    output_columns = _get_output_columns(visited_nodes, context)
    filters = _get_filters(visited_nodes, context)
    selectable = sql_context_helpers.get_node_selectable(node, context)
    query = select(output_columns).select_from(selectable).where(and_(*filters))
    return query
1165055
def select_node(**kw):
    
    with current_app.app_context():
        result = db.execute(text(fetch_query_string('select_node_from_id.sql')), **kw).fetchall()
        return result
156932
def filter(self, query: str) -> Optional['CompatNodeIterator']:
        
        if not self._last_node:
            return None

        return filter(self._last_node, query)
465244
def relationship(self, node):
        
        self._check_node(node)
        my_rel = _rel_helper(lhs='us', rhs='them', ident='r', **self.definition)
        q = "MATCH " + my_rel + " WHERE id(them)={them} and id(us)={self} RETURN r LIMIT 1"
        rels = self.source.cypher(q, {'them': node.id})[0]
        if not rels:
            return

        rel_model = self.definition.get('model') or StructuredRel

        return self._set_start_end_cls(rel_model.inflate(rels[0][0]), node)
503071
def filter(n: Node, query: str) -> CompatNodeIterator:
    
    ctx = uast()
    return CompatNodeIterator(NodeIterator(ctx.filter(query, n.internal_node), ctx))
1093247
def get_node(self, key):
        
        self._check_if_open()
        try:
            if not key.startswith('/'):
                key = '/' + key
            return self._handle.get_node(self.root, key)
        except _table_mod.exceptions.NoSuchNodeError:
            return None
721683
@Override
    public Node visitJoinRelation(SqlBaseParser.JoinRelationContext context)
    {
        Relation left = (Relation) visit(context.left);
        Relation right;

        if (context.CROSS() != null) {
            right = (Relation) visit(context.right);
            return new Join(getLocation(context), Join.Type.CROSS, left, right, Optional.empty());
        }

        JoinCriteria criteria;
        if (context.NATURAL() != null) {
            right = (Relation) visit(context.right);
            criteria = new NaturalJoin();
        }
        else {
            right = (Relation) visit(context.rightRelation);
            if (context.joinCriteria().ON() != null) {
                criteria = new JoinOn((Expression) visit(context.joinCriteria().booleanExpression()));
            }
            else if (context.joinCriteria().USING() != null) {
                criteria = new JoinUsing(visit(context.joinCriteria().identifier(), Identifier.class));
            }
            else {
                throw new IllegalArgumentException("Unsupported join criteria");
            }
        }

        Join.Type joinType;
        if (context.joinType().LEFT() != null) {
            joinType = Join.Type.LEFT;
        }
        else if (context.joinType().RIGHT() != null) {
            joinType = Join.Type.RIGHT;
        }
        else if (context.joinType().FULL() != null) {
            joinType = Join.Type.FULL;
        }
        else {
            joinType = Join.Type.INNER;
        }

        return new Join(getLocation(context), joinType, left, right, Optional.of(criteria));
    }
1124016
def connect(self, node, properties=None):
        
        if not hasattr(self.source, 'id'):
            raise ValueError("Node has not been saved cannot connect!")
        if len(self):
            raise AttemptedCardinalityViolation(
                "Node already has one relationship"
            )
        else:
            return super(One, self).connect(node, properties)
220995
def get_from_clause(self):
        
        result = super(MultilingualSQLCompiler, self).get_from_clause()

        if not self.query.include_translation_data:
            return result

        from_ = result[0]
        for join in self.query.extra_join.values():
            from_.append(join)
        return (from_, result[1])
678508
def parse(node)
      node.xpath('*').each do |node_children|
        case node_children.name
        when 'Relationship'
          @relationship << Relationship.new(parent: self).parse(node_children)
        end
      end
      self
    end
291593
def retrieve_nodes(self):
        
        self.verbose('retrieving nodes from old mysql DB...')

        self.old_nodes = list(OldNode.objects.all())
        self.message('retrieved %d nodes' % len(self.old_nodes))
319912
def get_node_type(tree):
    
    if isinstance(tree, (RSTTree, nltk.tree.Tree)):
        if tree.label() in ('N', 'S'):
            return tree.label()
        else:
            return 'relation'
    elif isinstance(tree, basestring):
        return 'edu'
    else:
        raise ValueError("Unknown tree/node type: {}".format(type(tree)))
319706
def to_qtree(self, instring, schema):
        
        root_list = self.to_syntax_tree(instring, schema)
        return qtree_translator.translate(root_list)
1236870
def get_relation_count_query_for_self_join(self, query, parent):
        
        query.select(QueryExpression('COUNT(*)'))

        table_prefix = self._query.get_query().get_connection().get_table_prefix()

        hash_ = self.get_relation_count_hash()
        query.from_('%s AS %s%s' % (self._table, table_prefix, hash_))

        key = self.wrap(self.get_qualified_parent_key_name())

        return query.where('%s.%s' % (hash_, self._foreign_key), '=', QueryExpression(key))