// Where sets where SQL
187229
func (b *Builder) Where(cond Cond) *Builder {
	if b.cond.IsValid() {
		b.cond = b.cond.And(cond)
	} else {
		b.cond = cond
	}
	return b
}
391831
func (engine *Engine) Where(query interface{}, args ...interface{}) *Session {
	session := engine.NewSession()
	session.isAutoClose = true
	return session.Where(query, args...)
}
215911
func (q *Qbs) WhereEqual(column string, value interface{}) *Qbs {
	q.criteria.condition = NewEqualCondition(column, value)
	return q
}
515731
func (tx *Tx) Query(sql string, args ...interface{}) (*Rows, error) {
	return tx.QueryEx(context.Background(), sql, nil, args...)
}
603314
func (session *Session) Sql(query string, args ...interface{}) *Session {
	return session.SQL(query, args...)
}
363681
func (b *SelectBuilder) Where(expr BoolExpr) *SelectBuilder {
	b.Select.Where = &Where{
		Type: astWhere,
		Expr: unwrapBoolExpr(expr),
	}
	return b
}
167428
func (p *aeDataQueryProperty) Filter(op string, value interface{}) *aeDataQueryBuilder {
	switch op {
	case "<=":
		p.LessThanOrEqual(value)
	case ">=":
		p.GreaterThanOrEqual(value)
	case "<":
		p.LessThan(value)
	case ">":
		p.GreaterThan(value)
	case "=":
		p.Equal(value)
	default:
		p.bldr.q = p.bldr.q.Filter(p.name+" "+op, value) // error raised by native query
	}
	if p.bldr.plugin != nil {
		p.bldr.plugin.Filter(p.name, op, value)
	}
	return p.bldr
}
962654
func (q *Query) WhereIn(where string, slice interface{}) *Query {
	return q.Where(where, types.InSlice(slice))
}
364366
func (db *DB) Select(dest interface{}, query string, args ...interface{}) error {
	return Select(db, dest, query, args...)
}
309027
func (b *DeleteBuilder) Where(w ...Cmp) *DeleteBuilder {
	b.where = append(b.where, w...)
	return b
}
779636
func (me *Dataset) Where(expressions ...Expression) *Dataset {
	expLen := len(expressions)
	if expLen > 0 {
		ret := me.copy()
		if ret.clauses.Where == nil {
			ret.clauses.Where = And(expressions...)
		} else {
			ret.clauses.Where = ret.clauses.Where.Append(expressions...)
		}
		return ret
	}
	return me
}
567882
func WhereOrg(org string) func(DocumentIndex, DocumentDecorator) ([]ID, error) {
	return func(idx DocumentIndex, _ DocumentDecorator) ([]ID, error) {
		oid, err := idx.FindOrganizationByName(org)
		if err != nil {
			return nil, err
		}
		return idx.GetAccessorsDocuments("org", oid)
	}
}
1144112
func (engine *Engine) Sql(querystring string, args ...interface{}) *Session {
	return engine.SQL(querystring, args...)
}
936260
func (engine *Engine) Query(sql string, paramStr ...interface{}) (resultsSlice []map[string][]byte, err error) {
	session := engine.NewSession()
	defer session.Close()
	return session.Query(sql, paramStr...)
}
1043844
func (session *Session) Query(sqlStr string, paramStr ...interface{}) (resultsSlice []map[string][]byte, err error) {
	defer session.resetStatement()
	if session.IsAutoClose {
		defer session.Close()
	}

	return session.query(sqlStr, paramStr...)
}
1198
func (q *Query) Select(fields ...string) *Query {
	for _, f := range fields {
		if strings.TrimSpace(f) != "" {
			q.addColumns = append(q.addColumns, f)
		}
	}
	return q
}
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()
}