sq

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 7 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Arg added in v0.3.0

func Arg(name string) litsql.Argument

Arg adds a named argument.

func ArgDefault added in v0.3.0

func ArgDefault(name string, defaultValue any) litsql.Argument

ArgDefault adds a named argument with a default value.

func ArgFunc added in v0.3.0

func ArgFunc(fn func() (any, error)) litsql.Argument

ArgFunc returns the argument value in a callback.

func DBArg added in v0.3.0

func DBArg(name string) litsql.Argument

DBArg adds a DB named argument.

func DBArgDefault added in v0.3.5

func DBArgDefault(name string, defaultValue any) litsql.Argument

DBArgDefault adds a DB named argument with a default value.

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

func ParseArgValues(args []any, values ...litsql.ArgValues) ([]any, error)

ParseArgValues replaces all litsql.Argument instances in args with named values.

func ParseArgs added in v0.3.0

func ParseArgs(args []any, values ...any) ([]any, error)

ParseArgs replaces all litsql.Argument instances in args with named values.

Types

type Args added in v0.3.3

type Args []any

Args wraps parseable argument results.

func Build added in v0.3.0

func Build(q litsql.Query, options ...BuildQueryOption) (string, Args, error)

Build builds a query string and its arguments.

func (Args) Parse added in v0.3.3

func (a Args) Parse(values ...any) ([]any, error)

func (Args) ParseValues added in v0.3.3

func (a Args) ParseValues(values ...litsql.ArgValues) ([]any, error)

type BuildQuery added in v0.3.0

type BuildQuery interface {
	Build(options ...BuildQueryOption) (string, Args, error)
}

BuildQuery builds query strings and arguments.

type BuildQueryOption added in v0.4.2

type BuildQueryOption = internal.BuildQueryOption

func WithBuildParseArgValues added in v0.5.2

func WithBuildParseArgValues(argValues ...litsql.ArgValues) BuildQueryOption

WithBuildParseArgValues adds named argument values.

func WithBuildParseArgs added in v0.5.2

func WithBuildParseArgs(argValues ...any) BuildQueryOption

WithBuildParseArgs adds named argument values.

func WithBuildWriterOptions added in v0.5.2

func WithBuildWriterOptions(writerOptions ...WriterOption) BuildQueryOption

WithBuildWriterOptions adds writer options.

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder implements litsql.QueryBuilder.

func NewQueryBuilder

func NewQueryBuilder(d litsql.Dialect) *Builder

func (*Builder) AddQueryClause added in v0.3.3

func (s *Builder) AddQueryClause(q litsql.QueryClause)

func (*Builder) Dialect

func (s *Builder) Dialect() litsql.Dialect

func (*Builder) QueryClauseList added in v0.3.3

func (s *Builder) QueryClauseList() ([]litsql.QueryClause, error)

type Mod

type Mod[T, A any] interface {
	ModTag[T]
	Apply(A)
}

Mod is a mod for a generic type.

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 QueryModApply[T any] interface {
	Apply(...QueryMod[T])
}

type WriterOption added in v0.3.0

type WriterOption = internal.WriterOption

func WithWriterIndentStr added in v0.3.0

func WithWriterIndentStr(indentStr string) WriterOption

WithWriterIndentStr sets the indent string (used only if WithWriterUseNewLine is true). Default is " " (two spaces).

func WithWriterUseNewLine added in v0.3.0

func WithWriterUseNewLine(useNewLine bool) WriterOption

WithWriterUseNewLine sets whether to use newlines in the output or not. Default is true.

Directories

Path Synopsis
reflectxargs module
structargs module

Jump to

Keyboard shortcuts

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