//Generates the WHERE clause for an SQL statement
510761
func (me *DefaultAdapter) WhereSql(buf *SqlBuilder, where ExpressionList) error {
	if where != nil && len(where.Expressions()) > 0 {
		buf.Write(me.WhereFragment)
		return me.Literal(buf, where)
	}
	return nil
}
1186753
func (c *Connection) Where(stmt string, args ...interface{}) *Query {
	q := Q(c)
	return q.Where(stmt, args...)
}
1080981
func where(X *mat.Dense, y mat.Vector, target int) *mat.Dense {
	n_obs, n_feats := X.Dims()
	var result []float64
	rows := 0
	for i := 0; i < n_obs; i++ {
		if int(y.At(i, 0)) == target {
			for j := 0; j < n_feats; j++ {
				result = append(result, X.At(i, j))
			}
			rows++
		}
	}
	X_i := mat.NewDense(rows, n_feats, result)
	return X_i
}
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
}
620667
func ParseSqlSelect(sqlQuery string) (*SqlSelect, error) {
	stmt, err := ParseSql(sqlQuery)
	if err != nil {
		return nil, err
	}
	sel, ok := stmt.(*SqlSelect)
	if !ok {
		return nil, fmt.Errorf("Expected SqlSelect but got %T", stmt)
	}
	return sel, nil
}
146311
func (qb *MySQLQueryBuilder) Where(cond string) QueryBuilder {
	qb.Tokens = append(qb.Tokens, "WHERE", cond)
	return qb
}
503700
func (ns *Namespace) Where(seq, key interface{}, args ...interface{}) (interface{}, error) {
	seqv, isNil := indirect(reflect.ValueOf(seq))
	if isNil {
		return nil, errors.New("can't iterate over a nil value of type " + reflect.ValueOf(seq).Type().String())
	}

	mv, op, err := parseWhereArgs(args...)
	if err != nil {
		return nil, err
	}

	var path []string
	kv := reflect.ValueOf(key)
	if kv.Kind() == reflect.String {
		path = strings.Split(strings.Trim(kv.String(), "."), ".")
	}

	switch seqv.Kind() {
	case reflect.Array, reflect.Slice:
		return ns.checkWhereArray(seqv, kv, mv, path, op)
	case reflect.Map:
		return ns.checkWhereMap(seqv, kv, mv, path, op)
	default:
		return nil, fmt.Errorf("can't iterate over %v", seq)
	}
}
813803
func (adapter *SQLiteAdapter) SelectLogQuery() string {
	query := `
		SELECT DISTINCT %s,%s FROM %s l WHERE %s = $1;`

	return Cleanf(query,
		types.SQLColumnLabelTableName, types.SQLColumnLabelEventName, // select
		types.SQLLogTableName,      // from
		types.SQLColumnLabelHeight) // where
}
783327
func (q Query) Where(predicate func(interface{}) bool) Query {
	return Query{
		Iterate: func() Iterator {
			next := q.Iterate()

			return func() (item interface{}, ok bool) {
				for item, ok = next(); ok; item, ok = next() {
					if predicate(item) {
						return
					}
				}

				return
			}
		},
	}
}
161619
func (s *DB) Where(query interface{}, args ...interface{}) *DB {
	return s.clone().search.Where(query, args...).db
}
363681
func (b *SelectBuilder) Where(expr BoolExpr) *SelectBuilder {
	b.Select.Where = &Where{
		Type: astWhere,
		Expr: unwrapBoolExpr(expr),
	}
	return b
}
952593
func GenerateInsertOuterQuery(ins *sqlparser.Insert) *sqlparser.ParsedQuery {
	buf := sqlparser.NewTrackedBuffer(nil)
	buf.Myprintf("%s %v%sinto %v%v values %a",
		ins.Action,
		ins.Comments,
		ins.Ignore,
		ins.Table,
		ins.Columns,
		":#values",
	)
	return buf.ParsedQuery()
}
1329691
func (c *ConflictUpdate) Where(expressions ...Expression) *ConflictUpdate {
	if c.WhereClause == nil {
		c.WhereClause = And(expressions...)
	} else {
		c.WhereClause = c.WhereClause.Append(expressions...)
	}
	return c
}
308586
func RedactSQLQuery(sql string) (string, error) {
	bv := map[string]*querypb.BindVariable{}
	sqlStripped, comments := SplitMarginComments(sql)

	stmt, err := Parse(sqlStripped)
	if err != nil {
		return "", err
	}

	prefix := "redacted"
	Normalize(stmt, bv, prefix)

	return comments.Leading + String(stmt) + comments.Trailing, nil
}
962654
func (q *Query) WhereIn(where string, slice interface{}) *Query {
	return q.Where(where, types.InSlice(slice))
}
455445
func (session *Session) Where(query interface{}, args ...interface{}) *Session {
	session.Statement.Where(query, args...)
	return session
}
1278257
func Compile(where criteria.Expression) (whereClause string, parameters []interface{}, joins []*TableJoin, err []error) {
	compiler := newExpressionCompiler()

	criteria.IteratePostOrder(where, bubbleUpJSONContext(&compiler))

	compiled := where.Accept(&compiler)

	c, ok := compiled.(string)
	if !ok {
		c = ""
	}

	// Make sure we don't return all possible joins but only the once that were
	// activated. Returning them as a slice preserves the correct order of
	// joins.
	joins, e := compiler.joins.GetOrderdActivatedJoins()
	if e != nil {
		compiler.err = append(compiler.err, e)
	}

	for _, j := range joins {
		if j.Where == "" {
			continue
		}
		if c != "" {
			c += " AND "
		}
		c += j.Where
	}

	return c, compiler.parameters, joins, compiler.err
}