Documentation ¶
Index ¶
- Variables
- func Express(w Writer, d Dialect, start int, e Expression) ([]any, error)
- func ExpressIf(w Writer, d Dialect, start int, e Expression, cond bool, ...) ([]any, error)
- func ExpressSlice(w Writer, d Dialect, start int, expressions []Expression, ...) ([]any, error)
- type Argument
- type ArgumentBase
- type DBNamedArgument
- type Dialect
- type DialectWithNamed
- type ExpressBuilder
- func (h *ExpressBuilder) Err() error
- func (h *ExpressBuilder) Express(e Expression)
- func (h *ExpressBuilder) ExpressIf(e Expression, cond bool, prefix, suffix Expression)
- func (h *ExpressBuilder) ExpressSlice(expressions []Expression, prefix, sep, suffix Expression)
- func (h *ExpressBuilder) Result() ([]any, error)
- func (h *ExpressBuilder) WriteQuery(e Query)
- type Expression
- type ExpressionFunc
- type NamedArgument
- type Query
- type QueryBuilder
- type QueryClause
- type QueryClauseMerge
- type QueryClauseMultiple
- type QueryFunc
- type ValuedArgument
- type Writer
Constants ¶
This section is empty.
Variables ¶
var (
ErrClause = errors.New("clause error")
)
Functions ¶
func ExpressIf ¶
func ExpressIf(w Writer, d Dialect, start int, e Expression, cond bool, prefix, suffix Expression) ([]any, error)
ExpressIf expands an express if the condition evaluates to true it can also add a prefix and suffix
func ExpressSlice ¶
func ExpressSlice(w Writer, d Dialect, start int, expressions []Expression, prefix, sep, suffix Expression) ([]any, error)
ExpressSlice is used to express a slice of expressions along with a prefix and suffix
Types ¶
type Argument ¶
type Argument interface {
// contains filtered or unexported methods
}
Argument is the base interface for query arguments.
type ArgumentBase ¶
type ArgumentBase struct{}
type DBNamedArgument ¶
DBNamedArgument is like NamedArgument but its value will be wrapped using [sql.Named].
type Dialect ¶
type Dialect interface { WriteArg(w Writer, position int) WriteQuoted(w Writer, s string) WriteCheckQuoted(w Writer, s string) }
Dialect implements dialect-specific methods.
type DialectWithNamed ¶
DialectWithNamed implements dialects that support db-specific named arguments.
type ExpressBuilder ¶
type ExpressBuilder struct {
// contains filtered or unexported fields
}
ExpressBuilder builds arguments in a sequence of Express calls.
func NewExpressBuilder ¶
func NewExpressBuilder(w Writer, d Dialect, start int) *ExpressBuilder
func (*ExpressBuilder) Err ¶
func (h *ExpressBuilder) Err() error
func (*ExpressBuilder) Express ¶
func (h *ExpressBuilder) Express(e Expression)
func (*ExpressBuilder) ExpressIf ¶
func (h *ExpressBuilder) ExpressIf(e Expression, cond bool, prefix, suffix Expression)
func (*ExpressBuilder) ExpressSlice ¶
func (h *ExpressBuilder) ExpressSlice(expressions []Expression, prefix, sep, suffix Expression)
func (*ExpressBuilder) Result ¶
func (h *ExpressBuilder) Result() ([]any, error)
func (*ExpressBuilder) WriteQuery ¶
func (h *ExpressBuilder) WriteQuery(e Query)
type Expression ¶
Expression is the base expression interface.
type ExpressionFunc ¶
ExpressionFunc is the functional implementation of Expression.
type NamedArgument ¶
NamedArgument represents an argument were its value will be provided by name.
type Query ¶
type Query interface { Expression WriteQuery(w Writer, start int) (args []any, err error) }
Query is the base interface for queries.
type QueryBuilder ¶
type QueryBuilder interface { Dialect() Dialect AddQueryClause(q QueryClause) }
QueryBuilder is the base interface for queries built by lists of clauses.
type QueryClause ¶
type QueryClause interface { Expression ClauseID() string ClauseOrder() int }
QueryClause is a query clause.
type QueryClauseMerge ¶
type QueryClauseMerge interface { QueryClause ClauseMerge(other QueryClause) }
QueryClauseMerge can be implemented by QueryClause when its data can be merged.
type QueryClauseMultiple ¶
type QueryClauseMultiple interface { QueryClause ClauseMultiple() }
QueryClauseMultiple can be implemented by QueryClause to signal multiple instances can be added.
type QueryFunc ¶ added in v0.3.2
type QueryFunc struct { D Dialect E Expression F func(w Writer, start int) (args []any, err error) // if nil, WriteSQL will be called directly. }
QueryFunc is a functional implementation of Query.
func (QueryFunc) WriteQuery ¶ added in v0.3.2
type ValuedArgument ¶
ValuedArgument represents an argument were its value will be provided by this instance.
type Writer ¶
type Writer interface { // Write writes a string. Write(s string) // WriteNewLine writes a newline if in newline-mode, or nothing if not. WriteNewLine() // WriteSeparator writes a newline if in newline-mode, or a space if not. WriteSeparator() // AddSeparator schedules a WriteSeparator to be written on the next Write, except on the first Write call. // If toplevel is true, will try to write a newline if enabled, if false will add a space. AddSeparator(topLevel bool) // StartQuery signals the writer that a new query (or subquery) will start. It resets the "first Write" flag. StartQuery() // Indent increases indentation by 1 (only in newline-mode). Indent() // Dedent decreases indentation by 1 (only in newline-mode). Dedent() // Err returns any errors that were generated in the write process. Err() error }
Writer is the interface used by expressions to output strings.