// inseryKiteQuery inserts the given kite, url and key to the kite.kite table
509454
func insertKiteQuery(kiteProt *protocol.Kite, url, keyId string) (string, []interface{}, error) {
	psql := sq.StatementBuilder.PlaceholderFormat(sq.Dollar)

	kiteValues := kiteProt.Values()
	values := make([]interface{}, len(kiteValues))

	for i, kiteVal := range kiteValues {
		values[i] = kiteVal
	}

	values = append(values, url)
	values = append(values, keyId)

	return psql.Insert("kite.kite").Columns(
		"username",
		"environment",
		"kitename",
		"version",
		"region",
		"hostname",
		"id",
		"url",
		"key_id",
	).Values(values...).ToSql()
}
14362
func (ctx *Context) Query(key string, defaults ...string) string {
	return (*Queries)(ctx.req).MustString(key, defaults...)
}
603343
func (g *GraphData) ToQuery() (ret *GraphQuery) {
	partials := map[string][]uint32{}
	for qid, qst := range g.Quests {
		// TODO(iannucci): handle q.Partial explicitly?
		for aid, atmpt := range qst.Attempts {
			if atmpt.Partial.Any() {
				partials[qid] = append(partials[qid], aid)
			}
		}
	}

	if len(partials) > 0 {
		ret = &GraphQuery{AttemptList: NewAttemptList(partials)}
	}
	return
}
141209
func (q *Query) WherePK() *Query {
	if !q.hasModel() {
		q.err(errModelNil)
		return q
	}

	if err := q.model.Table().checkPKs(); err != nil {
		q.err(err)
		return q
	}

	q.where = append(q.where, wherePKQuery{q})
	return q
}
1216960
func (c *Context) Query(key string) string {
	if c.query == nil {
		c.query = c.Request.URL.Query()
	}
	return c.query.Get(key)
}
684707
func (enc *Encoder) IntKey(key string, v int) {
	if enc.hasKeys {
		if !enc.keyExists(key) {
			return
		}
	}
	enc.grow(10 + len(key))
	r := enc.getPreviousRune()
	if r != '{' {
		enc.writeByte(',')
	}
	enc.writeByte('"')
	enc.writeStringEscape(key)
	enc.writeBytes(objKey)
	enc.buf = strconv.AppendInt(enc.buf, int64(v), 10)
}
931779
func paginationQuery(options *ListOptions) string {
	query := url.Values{}
	query.Set("limit", strconv.Itoa(options.Limit))
	query.Set("offset", strconv.Itoa(options.Offset))

	return query.Encode()
}
890101
func (q Query) ToSQL(model *Model, addColumns ...string) (string, []interface{}) {
	sb := q.toSQLBuilder(model, addColumns...)
	return sb.String(), sb.Args()
}
270619
func WithQueryCache(parent context.Context, value ...bool) context.Context {
	v := true
	if len(value) > 0 {
		v = value[0]
	}
	return context.WithValue(contextOrBackground(parent), keyQueryCache, v)
}
1026001
func (p PrefixTransform) InvertKey(k ds.Key) ds.Key {
	if p.Prefix.String() == "/" {
		return k
	}

	if !p.Prefix.IsAncestorOf(k) {
		panic("expected prefix not found")
	}

	s := k.String()[len(p.Prefix.String()):]
	return ds.RawKey(s)
}
253022
func IfErrWithKeys(l Logger, err error, intf ...interface{}) {
	if err != nil && l != nil {
		l.Log(append(intf, err)...)
	}
}
630315
func (ctx *Context) Query(key string) string {
	value, _ := ctx.GetQuery(key)
	return value
}
984372
func (b *RWSetBuilder) AddToRangeQuerySet(ns string, rqi *kvrwset.RangeQueryInfo) {
	nsPubRwBuilder := b.getOrCreateNsPubRwBuilder(ns)
	key := rangeQueryKey{rqi.StartKey, rqi.EndKey, rqi.ItrExhausted}
	_, ok := nsPubRwBuilder.rangeQueriesMap[key]
	if !ok {
		nsPubRwBuilder.rangeQueriesMap[key] = rqi
		nsPubRwBuilder.rangeQueriesKeys = append(nsPubRwBuilder.rangeQueriesKeys, key)
	}
}
265879
func (qe *QueryEngine) peekQuery(sql string) *TabletPlan {
	if cacheResult, ok := qe.plans.Peek(sql); ok {
		return cacheResult.(*TabletPlan)
	}
	return nil
}
738229
func NewIdsQuery(types ...string) IdsQuery {
	q := IdsQuery{
		types:  types,
		values: make([]string, 0),
		boost:  -1.0,
	}
	return q
}
1359959
func (scope *Scope) PrimaryKey() string {
	if field := scope.PrimaryField(); field != nil {
		return field.DBName
	}
	return ""
}
109596
func (irt *immutableRangeTree) Query(interval Interval) Entries {
	entries := NewEntries()

	irt.apply(irt.top, interval, 1, func(n *node) bool {
		entries = append(entries, n.entry)
		return true
	})

	return entries
}