where

package
v0.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2019 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

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.

func Offset

func Offset(n int) *queryConstraint

Offset sets the offset into the result set; previous items will be discarded.

func OrderBy

func OrderBy(column ...string) *queryConstraint

OrderBy lists the column(s) by which the database will be asked to sort its results. The columns passed in here will be quoted according to the needs of the current dialect.

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) Build

func (wh Clause) Build(dialect Dialect) (string, []interface{})

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.

func (Clause) String

func (wh Clause) String() string

type Condition

type Condition struct {
	Column, Predicate string
	Args              []interface{}
}

Condition is a simple condition such as an equality test.

func Between

func Between(column string, a, b interface{}) Condition

Between returns a between condition on a column.

func Eq

func Eq(column string, value interface{}) Condition

Eq returns an equality condition on a column.

func Gt

func Gt(column string, value interface{}) Condition

Gt returns a greater than condition on a column.

func GtEq

func GtEq(column string, value interface{}) Condition

GtEq returns a greater than or equal condition on a column.

func In

func In(column string, values ...interface{}) Condition

In returns an in condition on a column.

func Like

func Like(column string, pattern string) Condition

Like returns a pattern-matching condition on a column. Be careful: this can hurt performance.

func Lt

func Lt(column string, value interface{}) Condition

Lt returns a less than condition on a column.

func LtEq

func LtEq(column string, value interface{}) Condition

LtEq returns a less than or equal than condition on a column.

func NotEq

func NotEq(column string, value interface{}) Condition

NotEq returns a not equal condition on a column.

func NotNull

func NotNull(column string) Condition

NotNull returns an 'IS NOT NULL' condition on a column. It's also possible to use Not(Null(...)).

func Null

func Null(column string) Condition

Null returns an 'IS NULL' condition on a column.

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) Build

func (cl Condition) Build(dialect Dialect) (string, []interface{})

func (Condition) Or

func (cl Condition) Or(c2 Expression) Clause

Or combines two conditions into a clause that requires either is true.

func (Condition) String

func (cl Condition) String() string

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.

func Not

func Not(el Expression) Expression

Not negates an expression.

type QueryConstraint

type QueryConstraint interface {
	Build(dialect Dialect) string
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL