Build the query.
492267
protected function _beforeQuerySelect()
    {
        if($this->exclude_ids) {
          $this->where('location.id', 'NOT IN', $this->exclude_ids->toArray());
        }

        //nearby
        $nearby_latitude = null;
        $nearby_longitude = null;

        //nearby
        if( $this->locatable->geoLongitude && $this->locatable->geoLatitude ) {

          $nearby_latitude = $this->locatable->geoLatitude;
          $nearby_longitude = $this->locatable->geoLongitude;

        } elseif ($this->nearby_latitude && $this->nearby_longitude) {

            $nearby_latitude = $this->nearby_latitude;
            $nearby_longitude = $this->nearby_longitude;
        }

        //nearby
        if(!$this->keyword && $nearby_latitude && $nearby_longitude) {

          $earth_radius = 6371000;
          $lat = (float) $nearby_latitude;
          $lng = (float) $nearby_longitude;
          $calc_distance = 'CEIL((ACOS(SIN('.$lat.'*PI()/180) * SIN(location.geo_latitude*PI()/180) + COS('.$lat.'*PI()/180) * COS(location.geo_latitude*PI()/180) * COS(('.$lng.'*PI()/180) - (location.geo_longitude*PI()/180) )) *'.$earth_radius.'))';

          $this->select(array($calc_distance.' AS `distance`'));
          $this->having('distance < 5000');
          $this->order('distance', 'ASC');
        }
    }
1150422
public function build()
    {
        $values = array( 'access'           => false,
                         'genres'           => false,
                         'publication_date' => false,
                         'title'            => true,
                         'keywords'         => true,
                         'stock_tickers'    => true
        );
        foreach ($values as $value => $isEscaped) {
            if ( ! is_null( $this->{$value} )) {
                $this->addChild( sprintf( 'news:%s', $value ), $this->{$value}, $isEscaped );
            }
        }
    }
1079748
def compile_query(query):
    """"""
    if isinstance(query, dict):
        expressions = []
        for key, value in query.items():
            if key.startswith('$'):
                if key not in query_funcs:
                    raise AttributeError('Invalid operator: {}'.format(key))
                expressions.append(query_funcs[key](value))
            else:
                expressions.append(filter_query(key, value))
        if len(expressions) > 1:
            return boolean_operator_query(operator.and_)(expressions)
        else:
            return (
                expressions[0]
                if len(expressions)
                else lambda query_function: query_function(None, None)
            )
    else:
        return query
688928
public Query build() {
            Query.Builder root = this;
            while (true) {
                if (root.parent == null) {
                    break;
                }
                root = root.parent;
            }

            root.done();
            return root.tree;
        }
598020
public function build()
    {
        $value = $this->getValue();

        $this->uppercaseComparator();

        // Check for IS/IS NOT and set the value to NULL if it is.
        if ($this->isComparatorIsNotNullIsNull()) {
            $value = null;
        }

        // Check for IN/NOT IN and build a nice comma-separated list.
        if (!$this->isComparatorIsNotNullIsNull() && $this->isComparatorInNotIn() && is_array($value)) {
            $this->uppercaseComparator();
            $valueArray = [];
            foreach ($value as $valueItem) {
                if ($this->shouldQuoteValues()) {
                    $valueArray[] = $this->query->quote($valueItem);
                } else {
                    $valueArray[] = $valueItem;
                }
            }
            $value = '(' . implode(',', $valueArray) . ')';
        }

        // Now check if we need to still quote the value.
        if (!$this->isComparatorIsNotNullIsNull() && !$this->isComparatorInNotIn() && $this->shouldQuoteValues()) {
            $value = $this->query->quote($value);
        }

        // If we don't have IN/NOT IN, IS/NOT IS, and we shouldn't quote, we assume we're checking fields.
        if ($this->shouldCompareFields()) {
            $valueBuild = [
                $this->query->quoteIdentifier($this->getTableName()),
                '.',
                $this->query->quoteIdentifier($value),
            ];
            $value = implode($valueBuild);
        }

        $tableName = $this->getTableName();
        if ($this->getJoinTableName()) {
            $tableName = $this->getJoinTableName();
        }
        $tableName = $this->query->quoteIdentifier($tableName);

        $returnArray = [
            $tableName . '.' . $this->query->quoteIdentifier($this->getKey()),
            $this->getComparator(),
            $value,
        ];
        $returnString = implode(' ', $returnArray);

        return trim($returnString);
    }
790904
def build_query
      GraphQL.parse(BASE_QUERY).tap do |d_ast|
        selections = d_ast.definitions.first.selections.first.selections

        node_types.each do |type|
          selections << inline_fragment_ast(type) if include?(type)
        end

        selections.compact!
      end
    end
201210
public function build()
    {
        $query = $this->delegate->build();
        $this->utilityRegistry->addUtility(AdsUtility::SERVICE_QUERY_BUILDER);
        return $query;
    }
428957
public function buildQuery($query)
	{
		foreach($this->children as $child)
		{
			if($child->master!==null)
				$child->_joined=true;
			elseif($child->relation instanceof CHasOneRelation || $child->relation instanceof CBelongsToRelation
				|| $this->_finder->joinAll || $child->relation->together || (!$this->_finder->baseLimited && $child->relation->together===null))
			{
				$child->_joined=true;
				$query->join($child);
				$child->buildQuery($query);
			}
		}
	}
1245244
def _build_query(self, table, tree, visitor):
        
        kwargs = {}
        index = None
        if tree.using:
            index_name = kwargs["index"] = tree.using[1]
            index = table.get_index(index_name)
        if tree.where:
            constraints = ConstraintExpression.from_where(tree.where)
            possible_hash = constraints.possible_hash_fields()
            possible_range = constraints.possible_range_fields()
            if index is None:
                # See if we can find an index to query on
                indexes = table.get_matching_indexes(possible_hash, possible_range)
                if not indexes:
                    action = "scan"
                    kwargs["filter"] = constraints.build(visitor)
                    kwargs["expr_values"] = visitor.expression_values
                    kwargs["alias"] = visitor.attribute_names
                elif len(indexes) == 1:
                    index = indexes[0]
                    action = "query"
                    add_query_kwargs(kwargs, visitor, constraints, index)
                else:
                    names = ", ".join([index.name for index in indexes])
                    raise SyntaxError(
                        "No index specified with USING <index>, "
                        "but multiple possibilities for query: "
                        "%s" % names
                    )
            else:
                if index.hash_key in possible_hash:
                    action = "query"
                    add_query_kwargs(kwargs, visitor, constraints, index)
                else:
                    action = "scan"
                    if not index.scannable:
                        raise SyntaxError("Cannot scan local index %r" % index_name)
                    kwargs["filter"] = constraints.build(visitor)
                    kwargs["expr_values"] = visitor.expression_values
                    kwargs["alias"] = visitor.attribute_names
        else:
            action = "scan"
        return [action, kwargs, index]
49351
protected function createQuery()
    {
        $this->query = $this->connection->createSelect();
        $this->addFeatures();
        $this->addTypoScriptFilters();

        $this->setConfigurationValue('solarium', $this->query);
    }
1235200
def build(self, **values: Any) -> str:
        """"""
        converted_values = {
            key: self._converters[key].to_url(value)
            for key, value in values.items()
            if key in self._converters
        }
        result = self._builder.format(**converted_values).split('|', 1)[1]
        query_string = urlencode(
            {
                key: value
                for key, value in values.items()
                if key not in self._converters and key not in self.defaults
            },
            doseq=True,
        )
        if query_string:
            result = "{}?{}".format(result, query_string)
        return result
143050
def query(self):
        
        query = self._builder_class(
            self,
            self._query_grammar,
            self._post_processor,
            **self._builder_default_kwargs
        )

        return query
1154678
def _build_query(self, uri, params=None, action_token_type=None):
        """"""

        if params is None:
            params = QueryParams()

        params['response_format'] = 'json'

        session_token = None

        if action_token_type in self._action_tokens:
            # Favor action token
            using_action_token = True
            session_token = self._action_tokens[action_token_type]
        else:
            using_action_token = False
            if self._session:
                session_token = self._session['session_token']

        if session_token:
            params['session_token'] = session_token

        # make order of parameters predictable for testing
        keys = list(params.keys())
        keys.sort()

        query = urlencode([tuple([key, params[key]]) for key in keys])

        if not using_action_token and self._session:
            secret_key_mod = int(self._session['secret_key']) % 256

            signature_base = (str(secret_key_mod) +
                              self._session['time'] +
                              uri + '?' + query).encode('ascii')

            query += '&signature=' + hashlib.md5(signature_base).hexdigest()

        return query
1138447
def _build(lhs, rhs):
    """"""
    _check_under_condition()
    final_predicate, pred_set = _current_select()
    _check_and_add_pred_set(lhs, pred_set)
    _predicate_map.setdefault(lhs, []).append((final_predicate, rhs))
297584
public WebQuery buildQuery()
	{
		Map<String, List<String>> map = new HashMap<>(constraints);

		applyDefault(WQUriControlField.FETCH, map, defaultFetch);
		applyDefault(WQUriControlField.EXPAND, map, defaultExpand);
		applyDefault(WQUriControlField.ORDER, map, defaultOrder);
		applyDefault(WQUriControlField.OFFSET, map, "0");
		applyDefault(WQUriControlField.LIMIT, map, Integer.toString(defaultLimit));

		return new WebQuery().decode(map);
	}
447699
def __build_query(self, routine, parameters):
        """"""

        parameter_names = []
        replacements = {}
        for i, value in enumerate(parameters):
            name = 'arg' + str(i)

            parameter_names.append(name)
            replacements[name] = value

        parameter_pieces = []
        for i, name in enumerate(parameter_names):
            if i > 0:
                parameter_pieces.append(', ')

            # Embed encoded blobs directly.
            if issubclass(replacements[name].__class__, _BlobArgumentWrapper) is True:
                parameter_pieces.append(replacements[name].encoded)
                del replacements[name]
            else:
                parameter_pieces.append(':' + name)

        query = "CALL " + routine + "(" + ''.join(parameter_pieces) + ")"

        return (query, replacements)
1291815
protected function prepare_query() 
	{
		$this->query->where( $this->foreign_key, $this->local_model->{$this->local_key} )
			->limit( 1 );
	}