// Build builds the SELECT query and returns an executable Query object.
426992
func (s *SelectQuery) Build() *Query {
	params := Params{}
	for k, v := range s.params {
		params[k] = v
	}

	qb := s.builder.QueryBuilder()

	clauses := []string{
		qb.BuildSelect(s.selects, s.distinct, s.selectOption),
		qb.BuildFrom(s.from),
		qb.BuildJoin(s.join, params),
		qb.BuildWhere(s.where, params),
		qb.BuildGroupBy(s.groupBy),
		qb.BuildHaving(s.having, params),
	}
	sql := ""
	for _, clause := range clauses {
		if clause != "" {
			if sql == "" {
				sql = clause
			} else {
				sql += " " + clause
			}
		}
	}
	sql = qb.BuildOrderByAndLimit(sql, s.orderBy, s.limit, s.offset)
	if union := qb.BuildUnion(s.union, params); union != "" {
		sql = fmt.Sprintf("(%v) %v", sql, union)
	}

	return s.builder.NewQuery(sql).Bind(params)
}
563268
func Build(ctx sessionctx.Context, aggFuncDesc *aggregation.AggFuncDesc, ordinal int) AggFunc {
	switch aggFuncDesc.Name {
	case ast.AggFuncCount:
		return buildCount(aggFuncDesc, ordinal)
	case ast.AggFuncSum:
		return buildSum(aggFuncDesc, ordinal)
	case ast.AggFuncAvg:
		return buildAvg(aggFuncDesc, ordinal)
	case ast.AggFuncFirstRow:
		return buildFirstRow(aggFuncDesc, ordinal)
	case ast.AggFuncMax:
		return buildMaxMin(aggFuncDesc, ordinal, true)
	case ast.AggFuncMin:
		return buildMaxMin(aggFuncDesc, ordinal, false)
	case ast.AggFuncGroupConcat:
		return buildGroupConcat(ctx, aggFuncDesc, ordinal)
	case ast.AggFuncBitOr:
		return buildBitOr(aggFuncDesc, ordinal)
	case ast.AggFuncBitXor:
		return buildBitXor(aggFuncDesc, ordinal)
	case ast.AggFuncBitAnd:
		return buildBitAnd(aggFuncDesc, ordinal)
	}
	return nil
}
753136
func (e HashExp) Build(db *DB, params Params) string {
	if len(e) == 0 {
		return ""
	}

	// ensure the hash exp generates the same SQL for different runs
	names := []string{}
	for name := range e {
		names = append(names, name)
	}
	sort.Strings(names)

	var parts []string
	for _, name := range names {
		value := e[name]
		switch value.(type) {
		case nil:
			name = db.QuoteColumnName(name)
			parts = append(parts, name+" IS NULL")
		case Expression:
			if sql := value.(Expression).Build(db, params); sql != "" {
				parts = append(parts, "("+sql+")")
			}
		case []interface{}:
			in := In(name, value.([]interface{})...)
			if sql := in.Build(db, params); sql != "" {
				parts = append(parts, sql)
			}
		default:
			pn := fmt.Sprintf("p%v", len(params))
			name = db.QuoteColumnName(name)
			parts = append(parts, name+"={:"+pn+"}")
			params[pn] = value
		}
	}
	if len(parts) == 1 {
		return parts[0]
	}
	return strings.Join(parts, " AND ")
}
484916
func (r *Request) Build() {
	if !r.built {
		r.Handlers.Build.Run(r)
		r.built = true
		if r.Error != nil {
			return
		}
		r.Handlers.Sign.Run(r)
	}
}
267893
func (db *Database) buildWhere() string {
	var query bytes.Buffer
	whereSize := len(db.whereFields)
	if whereSize == 0 {
		db.panicLog("Please add a Where condition with .Where")
	}

	query.WriteString(" WHERE ")

	for j, clause := range db.whereFields {
		if strings.Contains(clause, "$") {
			query.WriteString(clause)
		} else {
			query.WriteString(handleIdentifier(clause))
			query.WriteString(" = $")
			query.WriteString(strconv.Itoa(db.varCount))
			db.varCount++
		}
		if j != whereSize-1 {
			query.WriteString(" AND ")
		}
	}
	query.WriteString(" ")
	return query.String()
}
923236
func (o *GetOrdersForItemURL) Build() (*url.URL, error) {
	var _result url.URL

	var _path = "/orders/{itemID}"

	itemID := o.ItemID
	if itemID != "" {
		_path = strings.Replace(_path, "{itemID}", itemID, -1)
	} else {
		return nil, errors.New("itemId is required on GetOrdersForItemURL")
	}

	_basePath := o._basePath
	if _basePath == "" {
		_basePath = "/api"
	}
	_result.Path = golangswaggerpaths.Join(_basePath, _path)

	return &_result, nil
}
510666
func (o *GetFqdnCacheIDURL) Build() (*url.URL, error) {
	var _result url.URL

	var _path = "/fqdn/cache/{id}"

	id := o.ID
	if id != "" {
		_path = strings.Replace(_path, "{id}", id, -1)
	} else {
		return nil, errors.New("id is required on GetFqdnCacheIDURL")
	}

	_basePath := o._basePath
	if _basePath == "" {
		_basePath = "/v1"
	}
	_result.Path = golangswaggerpaths.Join(_basePath, _path)

	qs := make(url.Values)

	var cidr string
	if o.Cidr != nil {
		cidr = *o.Cidr
	}
	if cidr != "" {
		qs.Set("cidr", cidr)
	}

	var matchpattern string
	if o.Matchpattern != nil {
		matchpattern = *o.Matchpattern
	}
	if matchpattern != "" {
		qs.Set("matchpattern", matchpattern)
	}

	_result.RawQuery = qs.Encode()

	return &_result, nil
}
582922
func (e *NotExp) Build(db *DB, params Params) string {
	if sql := e.e.Build(db, params); sql != "" {
		return "NOT (" + sql + ")"
	}
	return ""
}
977758
func (b *OpenAPI3Builder) build(document *openapiv3.Document) (err error) {
	// Collect service type descriptions from Components/Schemas.
	if document.Components != nil && document.Components.Schemas != nil {
		for _, pair := range document.Components.Schemas.AdditionalProperties {
			t, err := b.buildTypeFromSchemaOrReference(pair.Name, pair.Value)
			if err != nil {
				return err
			}
			if t != nil {
				b.model.addType(t)
			}
		}
	}
	// Collect service method descriptions from each PathItem.
	if document.Paths != nil {
		for _, pair := range document.Paths.Path {
			b.buildMethodFromPathItem(pair.Name, pair.Value)
		}
	}
	return err
}
123750
func (builder *StoreValueCommandBuilder) Build() (Command, error) {
	if builder.protobuf == nil {
		panic("builder.protobuf must not be nil")
	}
	if err := validateLocatable(builder.protobuf); err != nil {
		return nil, err
	}
	return &StoreValueCommand{
		value: builder.value,
		timeoutImpl: timeoutImpl{
			timeout: builder.timeout,
		},
		protobuf: builder.protobuf,
		resolver: builder.resolver}, nil
}
127722
func (fdb FileDictionaryBuilder) Build(dict *collection.Dictionary) (err error) {
	var handle *os.File
	handle, err = os.Open(fdb.Target)

	var currentLine string

	for {
		_, err = fmt.Fscanln(handle, &currentLine)

		switch err {
		case nil:
			dict.Add(currentLine)
		case io.EOF:
			err = nil
			fallthrough
		default:
			return
		}
	}
}
1239335
func (builder *SecondaryIndexQueryCommandBuilder) Build() (Command, error) {
	if builder.protobuf == nil {
		panic("builder.protobuf must not be nil")
	}
	if err := validateLocatable(builder.protobuf); err != nil {
		return nil, err
	}
	if builder.protobuf.GetKey() == nil &&
		(builder.protobuf.GetRangeMin() == nil || builder.protobuf.GetRangeMax() == nil) {
		return nil, newClientError("either WithIndexKey or WithRange are required", nil)
	}
	if builder.protobuf.GetStream() && builder.callback == nil {
		return nil, newClientError("SecondaryIndexQueryCommand requires a callback when streaming.", nil)
	}
	return &SecondaryIndexQueryCommand{
		timeoutImpl: timeoutImpl{
			timeout: builder.timeout,
		},
		protobuf: builder.protobuf,
		callback: builder.callback,
	}, nil
}
924153
func (b *EtcdTLSBuilder) Build(c *fi.ModelBuilderContext) error {
	// @check if tls is enabled and if so, we need to download the client certificates
	if !b.UseEtcdManager() && b.UseEtcdTLS() {
		name := "calico-client"
		dirname := "calico"
		ca := filepath.Join(dirname, "ca.pem")
		certificate := filepath.Join(dirname, name+".pem")
		key := filepath.Join(dirname, name+"-key.pem")

		if err := b.BuildCertificateTask(c, name, certificate); err != nil {
			return err
		}
		if err := b.BuildPrivateKeyTask(c, name, key); err != nil {
			return err
		}
		if err := b.BuildCertificateTask(c, fi.CertificateId_CA, ca); err != nil {
			return err
		}
	}

	return nil
}
1355886
func (e *EmptyService) Build(ctx context.Context, buildOptions options.Build) error {
	return nil
}
1341251
func Build(r *request.Request) {
	body := url.Values{
		"Action":  {r.Operation.Name},
		"Version": {r.ClientInfo.APIVersion},
	}
	if err := queryutil.Parse(body, r.Params, false); err != nil {
		r.Error = awserr.New("SerializationError", "failed encoding Query request", err)
		return
	}

	if !r.IsPresigned() {
		r.HTTPRequest.Method = "POST"
		r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
		r.SetBufferBody([]byte(body.Encode()))
	} else { // This is a pre-signed request
		r.HTTPRequest.Method = "GET"
		r.HTTPRequest.URL.RawQuery = body.Encode()
	}
}
1118537
func (builder *TsListKeysCommandBuilder) Build() (Command, error) {
	if builder.protobuf == nil {
		panic("builder.protobuf must not be nil")
	}
	if len(builder.protobuf.GetTable()) == 0 {
		return nil, ErrTableRequired
	}
	if builder.streaming && builder.callback == nil {
		return nil, newClientError("ListKeysCommand requires a callback when streaming.", nil)
	}
	if !builder.allowListing {
		return nil, ErrListingDisabled
	}
	return &TsListKeysCommand{
		timeoutImpl: timeoutImpl{
			timeout: builder.timeout,
		},
		protobuf:  builder.protobuf,
		streaming: builder.streaming,
		callback:  builder.callback,
	}, nil
}
793312
func (q *BaseQueryBuilder) BuildFrom(tables []string) string {
	if len(tables) == 0 {
		return ""
	}
	s := ""
	for _, table := range tables {
		table = q.quoteTableNameAndAlias(table)
		if s == "" {
			s = table
		} else {
			s += ", " + table
		}
	}
	return "FROM " + s
}