Documentation
¶
Overview ¶
Package query composes SQL fragments and binds named values for its generated dialect. It uses only the standard library and does not execute SQL.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidName = errors.New("invalid parameter name") ErrDuplicateBind = errors.New("parameter already bound") ErrMissingBind = errors.New("parameter has no binding") ErrUnusedBind = errors.New("binding is not used in SQL") ErrEmptyList = errors.New("cannot expand an empty list") ErrInvalidList = errors.New("cannot expand a nested list") ErrSyntax = errors.New("cannot scan SQL parameters") ErrMixedParameters = errors.New("use :name parameters instead of native placeholders") )
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder accumulates SQL and bindings. Its zero value is ready to use. Keep one builder per query; do not copy or mutate it concurrently with other calls. Bound values are retained, not deep-copied, and lists are expanded at Build time.
func New ¶
func New() *Builder
New creates a builder configured for the dialect of the generated models.
func (*Builder) Bind ¶
Bind registers a case-sensitive name without the colon. Names use ASCII letters, digits and underscores, and must not begin with a digit. Duplicate/invalid names are recorded as errors and reported by Build and Preview, allowing chaining.
func (*Builder) Build ¶
Build returns SQL with native placeholders and positional arguments in SQL order. It expands direct slices except byte slices and driver.Valuer implementations. Arrays and pointers remain scalar. Empty lists and unbound/unused names are errors. It does not evaluate Valuer methods, interpolate values, or validate SQL clauses. Every call compiles afresh and returns a new argument slice; values remain shared.