Documentation
¶
Index ¶
- func BuildExpression(wh Expression, dialect Dialect) (string, []interface{})
- func BuildQueryConstraint(qc QueryConstraint, dialect Dialect) string
- func Limit(n int) *queryConstraint
- func Offset(n int) *queryConstraint
- func OrderBy(column ...string) *queryConstraint
- type Clause
- type Condition
- func Between(column string, a, b interface{}) Condition
- func Eq(column string, value interface{}) Condition
- func Gt(column string, value interface{}) Condition
- func GtEq(column string, value interface{}) Condition
- func In(column string, values ...interface{}) Condition
- func Like(column string, pattern string) Condition
- func Lt(column string, value interface{}) Condition
- func LtEq(column string, value interface{}) Condition
- func NotEq(column string, value interface{}) Condition
- func NotNull(column string) Condition
- func Null(column string) Condition
- type Dialect
- type Expression
- type QueryConstraint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildExpression ¶ added in v0.8.0
func BuildExpression(wh Expression, dialect Dialect) (string, []interface{})
func BuildQueryConstraint ¶ added in v0.8.0
func BuildQueryConstraint(qc QueryConstraint, dialect Dialect) string
func Limit ¶ added in v0.8.0
func Limit(n int) *queryConstraint
Limit sets the upper limit on the number of records to be returned.
Types ¶
type Clause ¶
type Clause struct {
// contains filtered or unexported fields
}
Clause is a compound expression.
func And ¶
func And(exp ...Expression) Clause
And combines some expressions into a clause that requires they are all true.
func Or ¶
func Or(exp ...Expression) Clause
Or combines some expressions into a clause that requires that any is true.
func (Clause) And ¶
func (wh Clause) And(exp Expression) Clause
And combines two clauses into a clause that requires they are both true. SQL implementation note: AND has higher precedence than OR.
func (Clause) Or ¶
func (wh Clause) Or(exp Expression) Clause
Or combines two clauses into a clause that requires either is true. SQL implementation note: AND has higher precedence than OR.
type Condition ¶
type Condition struct {
Column, Predicate string
Args []interface{}
}
Condition is a simple condition such as an equality test.
func Like ¶ added in v0.20.0
Like returns a pattern-matching condition on a column. Be careful: this can hurt performance.
func NotNull ¶ added in v0.20.0
NotNull returns an 'IS NOT NULL' condition on a column. It's also possible to use Not(Null(...)).
func (Condition) And ¶
func (cl Condition) And(c2 Expression) Clause
And combines two conditions into a clause that requires they are both true.
func (Condition) Or ¶
func (cl Condition) Or(c2 Expression) Clause
Or combines two conditions into a clause that requires either is true.
type Dialect ¶
Dialect provides a method to convert named argument placeholders to the dialect needed for the database in use.
type Expression ¶
type Expression interface { And(Expression) Clause Or(Expression) Clause Build(dialect Dialect) (string, []interface{}) // contains filtered or unexported methods }
Expression is an element in a WHERE clause. Expressions may be nested in various ways.
func NoOp ¶
func NoOp() Expression
NoOp creates an empty expression. This is useful for conditionally chaining expressions based contextual decisions. It can also be passed to any method that need an expression but for which none is required in that case.
type QueryConstraint ¶ added in v0.8.0
QueryConstraint is a value that is appended to a SELECT statement.
func Literal ¶ added in v0.8.0
func Literal(sqlPart string) QueryConstraint
Literal returns the literal string supplied, converting it to a QueryConstraint.