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 ArgValues
- type Argument
- type ArgumentBase
- type DBNamedArgument
- type Dialect
- type DialectWithNamed
- type ExpressBuilder
- type Expression
- type ExpressionFunc
- type MapArgValues
- type NamedArgument
- type Query
- type QueryBuilder
- type QueryClause
- type QueryClauseMerge
- type QueryClauseMultiple
- 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) // quote only if string contains characters that need quoting. }
Dialect implements dialect-specific methods.
type DialectWithNamed ¶
DialectWithNamed implements dialects that support db-specific named arguments.
type ExpressBuilder ¶
type ExpressBuilder interface { Express(e Expression) ExpressIf(e Expression, cond bool, prefix, suffix Expression) ExpressSlice(expressions []Expression, prefix, sep, suffix Expression) WriteQuery(e Query) Result() ([]any, error) Err() error }
ExpressBuilder builds arguments in a sequence of Express calls.
func NewExpressBuilder ¶
func NewExpressBuilder(w Writer, d Dialect, start int) ExpressBuilder
type Expression ¶
Expression is the base expression interface.
type ExpressionFunc ¶
ExpressionFunc is the functional implementation of Expression.
type MapArgValues ¶
MapArgValues is an ArgValues backed from a map[string]any.
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) error }
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 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.