Documentation ¶
Index ¶
- func ArgFunc(fn func() (any, error)) litsql.Argument
- func Build(q litsql.Query, options ...BuildQueryOption) (string, []any, error)
- func DBNamedArg(name string, options ...ArgOption) litsql.Argument
- func NamedArg(name string, options ...ArgOption) litsql.Argument
- func NewWriter(w io.Writer, options ...WriterOption) litsql.Writer
- func ParseArgValues(args []any, values litsql.ArgValues) ([]any, error)
- func ParseArgs(args []any, values any) ([]any, error)
- type ArgOption
- type ArgsParser
- type BuildQuery
- type BuildQueryOption
- type Builder
- type Mod
- type ModTag
- type ModTagImpl
- type Query
- type QueryMod
- type QueryModApply
- type WriterOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DBNamedArg ¶ added in v0.5.7
DBNamedArg adds a DB-native named argument (for databases that support it). The end value will be wrapped in [sql.Named].
func NewWriter ¶ added in v0.3.0
func NewWriter(w io.Writer, options ...WriterOption) litsql.Writer
NewWriter creates the default implementation if litsql.Writer.
func ParseArgValues ¶ added in v0.3.3
ParseArgValues replaces all litsql.Argument instances in args with named values.
Types ¶
type ArgOption ¶ added in v0.5.7
type ArgOption func(options *argOptions)
func WithDefaultValue ¶ added in v0.5.7
WithDefaultValue sets a default value if the argument name was not passed.
type ArgsParser ¶ added in v0.6.0
type ArgsParser []any
ArgsParser wraps parseable argument results.
func (ArgsParser) ParseValues ¶ added in v0.6.0
func (a ArgsParser) ParseValues(values litsql.ArgValues) ([]any, error)
type BuildQuery ¶ added in v0.3.0
type BuildQuery interface {
Build(options ...BuildQueryOption) (string, []any, error)
}
BuildQuery builds query strings and arguments.
type BuildQueryOption ¶ added in v0.4.2
type BuildQueryOption = internal.BuildQueryOption
func WithParseArgValues ¶ added in v0.6.0
func WithParseArgValues(argValues litsql.ArgValues) BuildQueryOption
WithParseArgValues adds named argument values.
func WithParseArgs ¶ added in v0.6.0
func WithParseArgs(argValues any) BuildQueryOption
WithParseArgs adds named argument values.
func WithWriterOptions ¶ added in v0.6.0
func WithWriterOptions(writerOptions ...WriterOption) BuildQueryOption
WithWriterOptions adds writer options.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder implements litsql.QueryBuilder.
func NewQueryBuilder ¶
func (*Builder) AddQueryClause ¶ added in v0.3.3
func (s *Builder) AddQueryClause(q litsql.QueryClause)
func (*Builder) QueryClauseList ¶ added in v0.3.3
func (s *Builder) QueryClauseList() ([]litsql.QueryClause, error)
type ModTag ¶
type ModTag[T any] interface { // contains filtered or unexported methods }
ModTag is used just for interface tagging, so implementations for each dialect aren't accept on others.
type ModTagImpl ¶
type ModTagImpl[T any] struct { }
type Query ¶
type Query[T any] interface { litsql.QueryBuilder litsql.Query QueryModApply[T] BuildQuery }
Query is the interface for base queries.
type QueryMod ¶
type QueryMod[T any] interface { ModTag[T] Apply(qb litsql.QueryBuilder) }
QueryMod is a mod for litsql.QueryBuilder.
func QueryModFunc ¶
func QueryModFunc[T any](f func(apply litsql.QueryBuilder)) QueryMod[T]
type QueryModApply ¶
type WriterOption ¶ added in v0.3.0
type WriterOption = internal.WriterOption
func WithIndentString ¶ added in v0.6.0
func WithIndentString(indentString string) WriterOption
WithIndentString sets the indent string (used only if WithUseNewLine is true). Default is " " (two spaces).
func WithUseNewLine ¶ added in v0.6.0
func WithUseNewLine(useNewLine bool) WriterOption
WithUseNewLine sets whether to use newlines in the output or not. Default is true.