Documentation
¶
Index ¶
- Variables
- func Build(q Query) (string, []any, error)
- func BuildN(q Query, start int) (string, []any, error)
- func Express(w io.Writer, d Dialect, start int, e any) ([]any, error)
- func ExpressIf(w io.Writer, d Dialect, start int, e any, cond bool, prefix, suffix string) ([]any, error)
- func ExpressSlice[T any](w io.Writer, d Dialect, start int, expressions []T, prefix, sep, suffix string) ([]any, error)
- func MustBuild(q Query) (string, []any)
- func MustBuildN(q Query, start int) (string, []any)
- type BaseQuery
- func (b BaseQuery[E]) Apply(mods ...Mod[E])
- func (q BaseQuery[E]) Build() (string, []any, error)
- func (q BaseQuery[E]) BuildN(start int) (string, []any, error)
- func (b BaseQuery[E]) Clone() BaseQuery[E]
- func (q BaseQuery[E]) MustBuild() (string, []any)
- func (q BaseQuery[E]) MustBuildN(start int) (string, []any)
- func (b BaseQuery[E]) WriteQuery(w io.Writer, start int) ([]any, error)
- func (b BaseQuery[E]) WriteSQL(w io.Writer, _ Dialect, start int) ([]any, error)
- type Dialect
- type DialectWithNamed
- type Expression
- type ExpressionFunc
- type Mod
- type Query
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoNamedArgs = errors.New("Dialect does not support named arguments")
Functions ¶
func ExpressIf ¶
func ExpressIf(w io.Writer, d Dialect, start int, e any, cond bool, prefix, suffix string) ([]any, error)
ExpressIf expands an express if the condition evaluates to true it can also add a prefix and suffix
func ExpressSlice ¶
func ExpressSlice[T any](w io.Writer, d Dialect, start int, expressions []T, prefix, sep, suffix string) ([]any, error)
ExpressSlice is used to express a slice of expressions along with a prefix and suffix
Types ¶
type BaseQuery ¶
type BaseQuery[E Expression] struct { Expression E Dialect Dialect }
BaseQuery wraps common functionality such as cloning, applying new mods and the actual query interface implementation
func (BaseQuery[E]) MustBuild ¶
MustBuild builds the query and panics on error useful for initializing queries that need to be reused
func (BaseQuery[E]) MustBuildN ¶
MustBuildN builds the query and panics on error start numbers the arguments from a different point
func (BaseQuery[E]) WriteQuery ¶
type DialectWithNamed ¶
type DialectWithNamed interface {
Dialect
// WriteNamedArg should write an argument placeholder to the writer with the given name
WriteNamedArg(w io.Writer, name string)
}
Can also write namded args
type Expression ¶
type ExpressionFunc ¶
type Query ¶
type Query interface {
// It should satisfy the Expression interface so that it can be used
// in places such as a sub-select
// However, it is allowed for a query to use its own dialect and not
// the dialect given to it
Expression
// start is the index of the args, usually 1.
// it is present to allow re-indexing in cases of a subquery
// The method returns the value of any args placed
WriteQuery(w io.Writer, start int) (args []any, err error)
}
Click to show internal directories.
Click to hide internal directories.