Documentation
¶
Index ¶
- func AppendInClause(b *strings.Builder, column string, values []string, args *[]any)
- func ContainsFold(slice []string, value string) bool
- func ExecDeleteCount(ctx context.Context, db LifecycleSQL, query string, args ...any) (int64, error)
- func HasWildcard(values []string) bool
- func IsSQLiteDuplicateColumnError(err error) bool
- func IsSQLiteNoSuchTableError(err error) bool
- func IsSQLiteTransientLockError(err error) bool
- func NullIfBlank(value string) any
- func OriginSourceFromChatKey(chatKey string) string
- func SanitizeFTS5Pattern(raw string) string
- func SessionKeyMatchesSources(sessionKey string, sources []string) bool
- type LifecycleSQL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendInClause ¶
AppendInClause appends "column IN (?,?,...)" to a strings.Builder and adds the values to the args slice. It does not handle the leading AND/OR.
func ContainsFold ¶
ContainsFold reports whether slice contains value (case-insensitive comparison).
func ExecDeleteCount ¶
func ExecDeleteCount(ctx context.Context, db LifecycleSQL, query string, args ...any) (int64, error)
ExecDeleteCount executes a DELETE query and returns the number of rows affected.
func HasWildcard ¶
HasWildcard reports whether values contains "*".
func IsSQLiteDuplicateColumnError ¶
IsSQLiteDuplicateColumnError reports whether err is SQLite's duplicate-column migration error.
func IsSQLiteNoSuchTableError ¶
IsSQLiteNoSuchTableError reports whether err is SQLite's missing-table error.
func IsSQLiteTransientLockError ¶
IsSQLiteTransientLockError reports whether err is a retryable SQLite lock/busy error.
func NullIfBlank ¶
NullIfBlank returns nil for blank/whitespace values or the original string for non-blank values. Use when a blank string should be stored as SQL NULL.
func OriginSourceFromChatKey ¶
OriginSourceFromChatKey extracts the source prefix from a "source:chatID" chat key.
func SanitizeFTS5Pattern ¶
SanitizeFTS5Pattern removes punctuation that is unsafe in a SQLite FTS5 MATCH pattern while preserving word characters, whitespace, wildcard, plus, and quotes.
func SessionKeyMatchesSources ¶
SessionKeyMatchesSources checks whether a turn session key is allowed by a source filter. Turn rows match either the storage kind "turn" or the session key's adapter/source prefix (for example "discord"). If sources is empty or contains a wildcard, returns true.
Types ¶
type LifecycleSQL ¶
type LifecycleSQL interface {
ExecContext(context.Context, string, ...any) (sql.Result, error)
QueryContext(context.Context, string, ...any) (*sql.Rows, error)
QueryRowContext(context.Context, string, ...any) *sql.Row
}
LifecycleSQL is the minimal interface satisfied by both *sql.DB and *sql.Tx.