Build the :class:`QueryElement` representing this query.
420929
def construct(self):
        ''''''
        if self.__construct is None:
            self.__construct = self._construct()
        return self.__construct
264393
private function buildQuery()
    {
        $select = $this->buildSelect();

        $from = $this->buildFrom();

        $within = $this->buildWithin();

        $wheres = $this->buildWheres();

        $query = sprintf('%s %s %s %s', $select, $from, $within, $wheres);

        return trim($query);
    }
1351477
def build_queryset(self):
        """"""
        paths = [(os.path.join(self.build_prefix, 'index.html'), {})]
        self.request = None
        queryset = self.get_queryset()
        paginator = self.get_paginator(queryset, self.get_paginate_by(queryset))
        for page in paginator.page_range:
            paths.append(
                (os.path.join(self.build_prefix, 'page',
                              '%d' % page, 'index.html'), {'page': page}))
        for build_path, kwargs in paths:
            self.request = self.create_request(build_path)
            # Add a user with no permissions
            self.request.user = AnonymousUser()
            # Fake context so views work as expected
            self.kwargs = kwargs
            self.prep_directory(build_path)
            target_path = os.path.join(settings.BUILD_DIR, build_path)
            self.build_file(target_path, self.get_content())
150480
function buildQuery(query, builder = new Builder()) {
    for (let i = 0; i < query.length; i++) {
        const method = query[i]

        if (Array.isArray(method)) {
            builder.and(buildQuery(method, new NonCapture()))
            continue
        }

        if (!method instanceof Method) {
            // At this point, there should only be methods left, since all parameters are already taken care of.
            // If that's not the case, something didn't work out.
            throw new SyntaxException(`Unexpected statement: ${method}`)
        }

        const parameters = []
        // If there are parameters, walk through them and apply them if they don't start a new method.
        while (query[i + 1] && !(query[i + 1] instanceof Method)) {
            parameters.push(query[i + 1])

            // Since the parameters will be appended to the method object, they are already parsed and can be
            // removed from further parsing. Don't use unset to keep keys incrementing.
            query.splice(i + 1, 1)
        }

        try {
            // Now, append that method to the builder object.
            method.setParameters(parameters).callMethodOn(builder)
        } catch (e) {
            const lastIndex = parameters.length - 1
            if (Array.isArray(parameters[lastIndex])) {
                if (lastIndex !== 0) {
                    method.setParameters(parameters.slice(0, lastIndex))
                }
                method.callMethodOn(builder)
                builder.and(buildQuery(parameters[lastIndex], new NonCapture()))
            } else {
                throw new SyntaxException(`Invalid parameter given for ${method.origin}`)
            }
        }
    }

    return builder
}
691898
def query(self, *args, **kwargs):
        
        clone = self._clone()
        queries = []
        from pyes.query import Query

        if args:
            for f in args:
                if isinstance(f, Query):
                    queries.append(f)
                else:
                    raise TypeError('Only Query objects can be passed as argument')

        for field, value in kwargs.items():
            if value == [None]:
                value = ["$$$$"]
            queries.append(self._build_inner_query(field, value))

        clone._queries.extend(queries)
        return clone
498505
def build(self):
        
        if self.es_version == '1':
            if len(self.filters) > 0:
                return {
                    'filtered': {
                        'query': self.query,
                        'filter': {
                            'and': self.filters
                        }
                    }
                }
            else:
                return self.query
        else:
            query = {
                'bool': {
                    'must': self.query
                }
            }
            if len(self.filters) > 0:
                query["bool"]["filter"] = self.filters
            return query
1276158
def _buildElementTree(self,):
        
        t_binder = ctree.Element(self.name)

        for k,v in self.__dict__.items():
            if k not in ('name', 'urls', 'inputs', 'paging') and v :
                t_binder.set(k,v)

        self.etree = t_binder
        return t_binder
175669
def compile(self):
        
        # Can't tell if this is a hack or not. Revisit later
        self.context.set_query(self)

        # If any subqueries, translate them and add to beginning of query as
        # part of the WITH section
        with_frag = self.format_subqueries()

        # SELECT
        select_frag = self.format_select_set()

        # FROM, JOIN, UNION
        from_frag = self.format_table_set()

        # WHERE
        where_frag = self.format_where()

        # GROUP BY and HAVING
        groupby_frag = self.format_group_by()

        # ORDER BY
        order_frag = self.format_order_by()

        # LIMIT
        limit_frag = self.format_limit()

        # Glue together the query fragments and return
        query = '\n'.join(
            filter(
                None,
                [
                    with_frag,
                    select_frag,
                    from_frag,
                    where_frag,
                    groupby_frag,
                    order_frag,
                    limit_frag,
                ],
            )
        )
        return query
1012577
def parser():
    """"""
    query_parser = current_app.config['COLLECTIONS_QUERY_PARSER']
    if isinstance(query_parser, six.string_types):
        query_parser = import_string(query_parser)
        return query_parser
1299295
public function build(): QuerySelectorRequest
	{
		$instance = new QuerySelectorRequest();
		if ($this->nodeId === null) {
			throw new BuilderException('Property [nodeId] is required.');
		}
		$instance->nodeId = $this->nodeId;
		if ($this->selector === null) {
			throw new BuilderException('Property [selector] is required.');
		}
		$instance->selector = $this->selector;
		return $instance;
	}
924861
def build(self, **kwargs):
        
        build_args = dict(self.where_query)
        build_args.update(kwargs)
        record = self.model(**record_args(build_args))
        if self.join_args:
            # EXAMPLE:
            # Say we have a many-to-many relation like so:
            #   Post -> Tagging -> Tag
            # If we are adding a tag to a post, we need to create the tagging
            # in addition to the tag. To do this, we add a "related record" to
            # the tag which is the tagging. By building the previous record,
            # if it exists, we can recursively build a long object tree.
            # That is, when we do post.tags(), we get a query that looks like:
            # Query(Tag).joins("taggings").where(taggings={"post_id":post.id})
            # The call to "build" then creates a tag using kwargs and the where
            # constraint, and creates a tagging that looks like:
            # Tagging(post_id = post.id) and adds it to the tag's related
            # records. The tagging's tag_id is added once the tag is saved
            # which is the first time it gets an id
            # Join args will never have just one element
            next_to_build = getattr(self.record, self.join_args[-2]['table']).build()
            record._related_records.append(next_to_build)
        return record
1301598
def query(self):
        
        queryWidget = self.queryWidget()
        
        # check to see if there is an active container for this widget
        container = queryWidget.containerFor(self)
        if container:
            return container.query()
        
        elif QueryCompound.typecheck(self._query):
            return self._query
        
        # generate a new query from the editor
        column = self.uiColumnDDL.currentSchemaPath()
        plugin = self.currentPlugin()
        editor = self.editor()
        op     = self.uiOperatorDDL.currentText()
        
        if column and plugin:
            query = Query(column)
            plugin.setupQuery(query, op, editor)
            return query
        else:
            return Query()
891919
protected function build_query() {
        global $DB;

        // Get the required tables and fields.
        $joins = array();
        $fields = array('q.hidden', 'q.category');
        foreach ($this->requiredcolumns as $column) {
            $extrajoins = $column->get_extra_joins();
            foreach ($extrajoins as $prefix => $join) {
                if (isset($joins[$prefix]) && $joins[$prefix] != $join) {
                    throw new \coding_exception('Join ' . $join . ' conflicts with previous join ' . $joins[$prefix]);
                }
                $joins[$prefix] = $join;
            }
            $fields = array_merge($fields, $column->get_required_fields());
        }
        $fields = array_unique($fields);

        // Build the order by clause.
        $sorts = array();
        foreach ($this->sort as $sort => $order) {
            list($colname, $subsort) = $this->parse_subsort($sort);
            $sorts[] = $this->requiredcolumns[$colname]->sort_expression($order < 0, $subsort);
        }

        // Build the where clause.
        $tests = array('q.parent = 0');
        $this->sqlparams = array();
        foreach ($this->searchconditions as $searchcondition) {
            if ($searchcondition->where()) {
                $tests[] = '((' . $searchcondition->where() .'))';
            }
            if ($searchcondition->params()) {
                $this->sqlparams = array_merge($this->sqlparams, $searchcondition->params());
            }
        }
        // Build the SQL.
        $sql = ' FROM {question} q ' . implode(' ', $joins);
        $sql .= ' WHERE ' . implode(' AND ', $tests);
        $this->countsql = 'SELECT count(1)' . $sql;
        $this->loadsql = 'SELECT ' . implode(', ', $fields) . $sql . ' ORDER BY ' . implode(', ', $sorts);
    }
765311
def _query(options, collection_name, num_to_skip,
           num_to_return, query, field_selector, opts, check_keys):
    """"""
    encoded = _dict_to_bson(query, check_keys, opts)
    if field_selector:
        efs = _dict_to_bson(field_selector, False, opts)
    else:
        efs = b""
    max_bson_size = max(len(encoded), len(efs))
    return b"".join([
        _pack_int(options),
        _make_c_string(collection_name),
        _pack_int(num_to_skip),
        _pack_int(num_to_return),
        encoded,
        efs]), max_bson_size
462797
public function buildQueryBuilder()
    {
        $builder = new QueryBuilder();

        foreach ($this->parsers as $parser) {
            if ($parser->wasApplied()) {
                $parser->apply($builder);
            }
        }

        foreach ($this->sorts as $sort) {
            $builder->orderBy($sort[0], $sort[1]);
        }

        if (!empty($this->perPage)) {
            $builder->setPageSize($this->perPage);
        }

        if (!empty($this->page)) {
            $builder->setPage($this->page);
        }

        if (!empty($this->searchQuery)) {
            $builder->setSearchQuery($this->searchQuery);
        }

        return $builder;
    }
789923
def query( self ):
        
        # create the query compound
        if ( self.childCount() ):
            q = Q()
            operator = 'and'
            for i in range(self.childCount()):
                item = self.child(i)
                if ( isinstance(item, XQueryItem) ):
                    if ( operator == 'and' ):
                        q &= item.query()
                    else:
                        q |= item.query()
                else:
                    operator = nativestring(item.text(0))
            return q
        
        # create the query for this individual item
        else:
            q = Q(self.columnName())
            q.setOperatorType(self.operatorType())
            q.setValue(self.value())
            return q
1279060
def fromElement(cls, elem):
        

        self = cls()

        self.oid = elem.get("OID")
        self.name = elem.get("Name")
        return self