// Idempotent marks the query as being idempotent or not depending on
// the value.
172813
func (q *Queryx) Idempotent(value bool) *Queryx {
	q.Query.Idempotent(value)
	return q
}
1085023
func (q Query) SelectManyIndexedT(selectorFn interface{}) Query {

	selectManyIndexedGenericFunc, err := newGenericFunc(
		"SelectManyIndexedT", "selectorFn", selectorFn,
		simpleParamValidator(newElemTypeSlice(new(int), new(genericType)), newElemTypeSlice(new(Query))),
	)
	if err != nil {
		panic(err)
	}

	selectorFunc := func(index int, inner interface{}) Query {
		return selectManyIndexedGenericFunc.Call(index, inner).(Query)
	}

	return q.SelectManyIndexed(selectorFunc)
}
1069811
func (d *Decoder) DecodeElement(v interface{}) error {
	if d.TokenType != StartElement {
		return fmt.Errorf("xmlp.DecodeElement: not StartElement")
	}

	token := d.token.(xml.StartElement)
	err := d.client.DecodeElement(v, &token)
	if err != nil {
		return err
	}

	local := d.Local
	d.resetState()
	d.TokenType = EndElement
	d.Local = local
	d.token = nil
	return nil
}
230492
func (db *dimensionalBundle) Compare(e common.Comparator) int {
	keyed := e.(keyed)
	if db.id == keyed.key() {
		return 0
	}

	if db.id > keyed.key() {
		return 1
	}

	return -1
}
739203
func NewTemporal(id string, t time.Time) (*Predicate, error) {
	if id == "" {
		return nil, fmt.Errorf("predicate.NewTemporal(%q, %v) cannot create a temporal predicate  with empty ID", id, t)
	}
	return &Predicate{
		id:     ID(id),
		anchor: &t,
	}, nil
}
602152
func (q *Query) Relation(name string, apply ...func(*Query) (*Query, error)) *Query {
	var fn func(*Query) (*Query, error)
	if len(apply) == 1 {
		fn = apply[0]
	} else if len(apply) > 1 {
		panic("only one apply function is supported")
	}

	join := q.model.Join(name, fn)
	if join == nil {
		return q.err(fmt.Errorf("%s does not have relation=%q",
			q.model.Table(), name))
	}

	if fn == nil {
		return q
	}

	switch join.Rel.Type {
	case HasOneRelation, BelongsToRelation:
		q.joinAppendOn = join.AppendOn
		return q.Apply(fn)
	default:
		q.joinAppendOn = nil
		return q
	}
}
314812
func (ev *QueryEvent) FormattedQuery() (string, error) {
	b, err := appendQuery(ev.DB, nil, ev.Query, ev.Params...)
	if err != nil {
		return "", err
	}
	return string(b), nil
}
622101
func (p *aeDataQueryProperty) LessThanOrEqual(value interface{}) *aeDataQueryBuilder {
	p.bldr.q = p.bldr.q.Filter(p.name+" <=", value)
	if p.bldr.plugin != nil {
		p.bldr.plugin.Filter(p.name, "<=", value)
	}
	return p.bldr
}
303265
func NewTermQuery(name string, value interface{}) TermQuery {
	t := TermQuery{name: name, value: value}
	return t
}
75949
func (q *TagQuery) getInitialByEqual(expr kv, idCh chan schema.MKey, stopCh chan struct{}) {
	defer q.wg.Done()

KEYS:
	for k := range q.index[expr.key][expr.value] {
		select {
		case <-stopCh:
			break KEYS
		case idCh <- k:
		}
	}

	close(idCh)
}
1279507
func (d *DMI) GenericSearchBy(param, value string) ([]Record, error) {
	if len(d.Data) == 0 {
		return nil, fmt.Errorf("DMI data is empty; make sure to .Run() first")
	}

	var records []Record

	for _, v := range d.Data {
		for _, d := range v {
			if d[param] != value {
				continue
			}

			records = append(records, d)
		}
	}

	return records, nil
}
349854
func (q *IdsQuery) Source() (interface{}, error) {
	// {
	//	"ids" : {
	//		"type" : "my_type",
	//		"values" : ["1", "4", "100"]
	//	}
	// }

	source := make(map[string]interface{})
	query := make(map[string]interface{})
	source["ids"] = query

	// type(s)
	if len(q.types) == 1 {
		query["type"] = q.types[0]
	} else if len(q.types) > 1 {
		query["types"] = q.types
	}

	// values
	query["values"] = q.values

	if q.boost != nil {
		query["boost"] = *q.boost
	}
	if q.queryName != "" {
		query["_name"] = q.queryName
	}

	return source, nil
}
31507
func (o *QueryTypeOption) Equal(o2 *QueryTypeOption) bool {
	if o2 == nil {
		return o.value == "prefixLast"
	}
	return o.value == o2.value
}
310902
func ValidateResourceIDOrEmpty(i interface{}, k string) (_ []string, errors []error) {
	v, ok := i.(string)
	if !ok {
		errors = append(errors, fmt.Errorf("expected type of %q to be string", k))
		return
	}

	if v == "" {
		return
	}

	return ValidateResourceID(i, k)
}
933565
func maybeExpandNamedQueryAndExec(e SqlExecutor, query string, args ...interface{}) (sql.Result, error) {
	dbMap := extractDbMap(e)

	if len(args) == 1 {
		query, args = maybeExpandNamedQuery(dbMap, query, args)
	}

	return exec(e, query, args...)
}
973254
func (p *parser) parseEqualityExpr(n node) node {
	opnd := p.parseRelationalExpr(n)
Loop:
	for {
		var op string
		switch p.r.typ {
		case itemEq:
			op = "="
		case itemNe:
			op = "!="
		default:
			break Loop
		}
		p.next()
		opnd = newOperatorNode(op, opnd, p.parseRelationalExpr(n))
	}
	return opnd
}
317579
func (p *parser) parseAdditiveExpr(n node) node {
	opnd := p.parseMultiplicativeExpr(n)
Loop:
	for {
		var op string
		switch p.r.typ {
		case itemPlus:
			op = "+"
		case itemMinus:
			op = "-"
		default:
			break Loop
		}
		p.next()
		opnd = newOperatorNode(op, opnd, p.parseMultiplicativeExpr(n))
	}
	return opnd
}