Documentation
¶
Index ¶
- func Alias(table, column string) string
- func Collect(ctx context.Context, f Fragment) (string, []any)
- func IsNil(e Fragment) bool
- func NonNil[F Fragment](seq iter.Seq[F]) iter.Seq[Fragment]
- func Stringify(f Fragment) string
- type CustomValueArg
- type Fragment
- func Arg(v any) Fragment
- func ArgIterFunc(v any) Fragment
- func Block(f Fragment) Fragment
- func BlockWithoutBrackets(seq iter.Seq[Fragment]) Fragment
- func Compose(sep string, frags ...Fragment) Fragment
- func ComposeSeq(sep string, frags iter.Seq[Fragment]) Fragment
- func Empty() Fragment
- func Func(f func(context.Context) Iter) Fragment
- func Lit(q string) Fragment
- func Query(query string, args ...any) Fragment
- type Iter
- type NamedArg
- type NamedArgs
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Alias ¶
Alias generates a deterministic alias name for a given table and column. If the combined length is shorter than 64 characters (minus separators), it returns a simple "table__column" alias. Otherwise, it generates a hashed form using a cached SHA1-based abbreviation to keep the alias short and stable.
Types ¶
type CustomValueArg ¶
type CustomValueArg interface {
ValueEx() string
}
CustomValueArg supports replacing ? to some sql snippet eg: ? => UPPER(?)
type Fragment ¶
type Fragment interface {
// IsNil reports whether the fragment is empty.
IsNil() bool
// Frag yields SQL text chunks and their bound arguments.
Frag(ctx context.Context) Iter
}
Fragment is a SQL fragment that yields query pieces and arguments.
func BlockWithoutBrackets ¶
BlockWithoutBrackets joins fragments with commas, without surrounding parentheses.
func ComposeSeq ¶
ComposeSeq joins an iterator of fragments with sep, skipping nil fragments.
type Iter ¶
Iter will yield a SQL fragment with a raw query(string with holder) and values eg:
query = INSERT INTO t_table (f_x,f_y,f_z) VALUES (?,?,?) args = 1, '2', 3.0