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 ¶
func BuildExpression(wh Expression, dialect Dialect) (string, []interface{})
func BuildQueryConstraint ¶
func BuildQueryConstraint(qc QueryConstraint, dialect Dialect) string
func Limit ¶
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 ¶
Like returns a pattern-matching condition on a column. Be careful: this can hurt performance.
func NotNull ¶
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 ¶
type Dialect interface { ReplacePlaceholders(sql string, args []interface{}) string Quote(column string) string }
Dialect provides a method to convert named argument placeholders to the dialect needed for the database in use.
type Expression ¶
type Expression interface { fmt.Stringer 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 ¶
QueryConstraint is a value that is appended to a SELECT statement.
func Literal ¶
func Literal(sqlPart string) QueryConstraint
Literal returns the literal string supplied, converting it to a QueryConstraint.