bind

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UNKNOWN = iota
	QUESTION
	DOLLAR
	NAMED
	AT
)

Bindvar types supported by Rebind, BindMap and BindStruct.

Variables

View Source
var ErrBindMismatch = errors.New("sqlx: bind count mismatch")

ErrBindMismatch is returned when there is a mismatch between binding variables and parameters.

View Source
var ErrColumnNotFound = errors.New("sqlx: column not found")

ErrColumnNotFound is returned when a column from the database cannot be mapped to a destination.

View Source
var ErrNamedPropertyNotFound = errors.New("sqlx: named property not found")

ErrNamedPropertyNotFound is returned when a named parameter cannot be found in the provided struct or map.

View Source
var ErrSyntax = errors.New("sqlx: query syntax error")

ErrSyntax is returned when there is a syntax error in the query parsing.

View Source
var ErrUnsupportedType = errors.New("sqlx: unsupported type")

ErrUnsupportedType is returned when an unsupported type is provided for binding.

Functions

func BindAnyArgs

func BindAnyArgs(names []string, arg any, m *reflectx.Mapper) ([]any, error)

BindAnyArgs is public mapping logic used by named queries to bind struct args dynamically.

func BindDriver

func BindDriver(driverName string, bindType int)

BindDriver sets the BindType for driverName to bindType.

func BindNamed

func BindNamed(bindType int, query string, arg any) (string, []any, error)

BindNamed binds a struct or a map to a query with named parameters.

func BindType

func BindType(driverName string) int

BindType returns the bindtype for a given database given a drivername.

func CompileNamedQuery

func CompileNamedQuery(qs []byte, bindType int) (query string, names []string, err error)

CompileNamedQuery is public mapping logic used by the prepared named queries internally. It returns a defensive copy of the cached names slice to prevent external callers from poisoning the compile cache (e.g. via NamedStmt.Params mutation).

func In

func In(query string, args ...any) (string, []any, error)

In expands slice values in args, returning the modified query string and a new arg list that can be executed by a database. The `query` should use the `?` bindVar. The return value uses the `?` bindVar.

func Named

func Named(query string, arg any) (string, []any, error)

Named takes a query using named parameters and an argument and returns a new query.

func Rebind

func Rebind(bindType int, query string) string

Rebind a query from the default bindtype (QUESTION) to the target bindtype.

Types

This section is empty.

Jump to

Keyboard shortcuts

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