Documentation
¶
Overview ¶
Package condition provides a sql condition builder.
Index ¶
Constants ¶
View Source
const ( WHERE = iota + 1 HAVING LIMIT ORDER OFFSET GROUP JOIN )
Allowed conditions.
View Source
const ( LEFT = iota + 1 RIGHT INNER CROSS )
Allowed join types.
View Source
const PLACEHOLDER = "?"
PLACEHOLDER character.
Variables ¶
View Source
var ( ErrValue = "query: %s was called with no value(s)" ErrCrossJoin = errors.New("query: cross joins are not allowed to have a join condition") ErrJoinType = "query: join type %d is not allowed" ErrJoinTable = errors.New("query: join table is mandatory") ErrPlaceholderMismatch = "query: %v placeholder(%d) and arguments(%d) does not fit" )
Error messages.
Functions ¶
func ReplacePlaceholders ¶
func ReplacePlaceholders(stmt string, p Placeholder) string
ReplacePlaceholders will replace the query placeholder with any other placeholder.
Types ¶
type Clause ¶
type Clause interface { Arguments() []interface{} Condition() string }
Clause interface.
type Condition ¶
type Condition interface { SetWhere(condition string, args ...interface{}) Condition Where() []Clause SetJoin(joinType int, table string, condition string, args ...interface{}) Condition Join() []Clause SetHaving(condition string, args ...interface{}) Condition Having() []Clause SetLimit(limit int) Condition Limit() int SetOffset(offset int) Condition Offset() int SetGroup(group ...string) Condition Group() []string SetOrder(order ...string) Condition Order() []string Copy() Condition Merge(Condition) Reset(...int) Error() error Render(b Placeholder) (string, []interface{}, error) }
Condition interface.
type Placeholder ¶
type Placeholder struct { Numeric bool // must be true if the database uses something like $1,$2,... Char string // database placeholder character // contains filtered or unexported fields }
Placeholder is used to ensure an unique placeholder for different database adapters.
Click to show internal directories.
Click to hide internal directories.