//Condition defines the SQL "WHERE" clause
//If other condition can be inferred by the struct argument in
//Find method, it will be merged with AND
494169
func (q *Qbs) Condition(condition *Condition) *Qbs {
	q.criteria.condition = condition
	return q
}
1282522
func (p *ConnPool) Query(sql string, args ...interface{}) (*Rows, error) {
	c, err := p.Acquire()
	if err != nil {
		// Because checking for errors can be deferred to the *Rows, build one with the error
		return &Rows{closed: true, err: err}, err
	}

	rows, err := c.Query(sql, args...)
	if err != nil {
		p.Release(c)
		return rows, err
	}

	rows.connPool = p

	return rows, nil
}
404736
func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool {
	if h, ok := t.(tHelper); ok {
		h.Helper()
	}
	result := comp()
	if !result {
		Fail(t, "Condition failed!", msgAndArgs...)
	}
	return result
}
1186753
func (c *Connection) Where(stmt string, args ...interface{}) *Query {
	q := Q(c)
	return q.Where(stmt, args...)
}
1303319
func (q *Qbs) Where(expr string, args ...interface{}) *Qbs {
	q.criteria.condition = NewCondition(expr, args...)
	return q
}
420230
func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool {
	if h, ok := t.(tHelper); ok {
		h.Helper()
	}
	return Condition(t, comp, append([]interface{}{msg}, args...)...)
}
608422
func (cs Conditions) AddCondition(key string, c Condition) {
	cs[key] = c
}
1332815
func (q *Query) Having(condition string, args ...interface{}) *Query {
	if q.RawSQL.Fragment != "" {
		log(logging.Warn, "Query is setup to use raw SQL")
		return q
	}
	q.havingClauses = append(q.havingClauses, HavingClause{condition, args})

	return q
}
1222468
func (a *SetBreakpointArgs) SetCondition(condition string) *SetBreakpointArgs {
	a.Condition = &condition
	return a
}
635912
func (query Query) Join(collection string, condition ...c.Condition) Query {
	return query.JoinWith("JOIN", collection, condition...)
}
900006
func (scope *Scope) CombinedConditionSql() string {
	joinSQL := scope.joinsSQL()
	whereSQL := scope.whereSQL()
	if scope.Search.raw {
		whereSQL = strings.TrimSuffix(strings.TrimPrefix(whereSQL, "WHERE ("), ")")
	}
	return joinSQL + whereSQL + scope.groupSQL() +
		scope.havingSQL() + scope.orderSQL() + scope.limitAndOffsetSQL()
}
1362989
func Not(inner ...Condition) Condition {
	if len(inner) == 1 {
		c := inner[0]
		switch c.Type {
		case ConditionEq:
			c.Type = ConditionNe
			return c
		case ConditionLt:
			c.Type = ConditionGte
			return c
		case ConditionLte:
			c.Type = ConditionGt
			return c
		case ConditionGt:
			c.Type = ConditionLte
			return c
		case ConditionGte:
			c.Type = ConditionLt
			return c
		case ConditionNil:
			c.Type = ConditionNotNil
			return c
		case ConditionIn:
			c.Type = ConditionNin
			return c
		case ConditionLike:
			c.Type = ConditionNotLike
			return c
		}
	}

	return Condition{
		Type:  ConditionNot,
		Inner: inner,
	}
}
183067
func (q Query) WhereT(predicateFn interface{}) Query {

	predicateGenericFunc, err := newGenericFunc(
		"WhereT", "predicateFn", predicateFn,
		simpleParamValidator(newElemTypeSlice(new(genericType)), newElemTypeSlice(new(bool))),
	)
	if err != nil {
		panic(err)
	}

	predicateFunc := func(item interface{}) bool {
		return predicateGenericFunc.Call(item).(bool)
	}

	return q.Where(predicateFunc)
}
962654
func (q *Query) WhereIn(where string, slice interface{}) *Query {
	return q.Where(where, types.InSlice(slice))
}
1209682
func (b *UpdateBuilder) Where(expr BoolExpr) *UpdateBuilder {
	b.Update.Where = &Where{
		Type: astWhere,
		Expr: unwrapBoolExpr(expr),
	}
	return b
}
263253
func (statement *Statement) Join(joinOP string, tablename interface{}, condition string, args ...interface{}) *Statement {
	return statement.join(joinOP, tablename, condition, args...)
}
1198770
func condition(name string, input interface{}, template interface{}, options *ProcessorOptions) interface{} {
	if v, ok := input.(string); ok {

		if v, ok := retrieveCondition(input, template); ok {
			return v
		}

		if c := getCondition(v, template); c != nil {
			res := search(c, template, options)
			// replace the value in the template so the value can be reused
			setCondition(v, res, template)

			return res
		}
	}

	return nil
}