Documentation
¶
Overview ¶
Package query reads, splits, and classifies SQL input.
Index ¶
- Variables
- func AnalysisText(sql string) string
- func CommentlessText(sql string) string
- func HasToken(tokens []string, token string) bool
- func HasTokenSequence(tokens []string, sequence ...string) bool
- func Mutating(sql string) bool
- func Read(src Source) (string, error)
- func Statements(sql string) []string
- func Tokens(sql string) []string
- type Danger
- type Source
- type Statement
Constants ¶
This section is empty.
Variables ¶
var ErrMultipleInputs = errors.New("specify only one of --sql, --file, or stdin")
ErrMultipleInputs is returned when SQL is supplied through more than one supported source at the same time.
Functions ¶
func AnalysisText ¶
AnalysisText returns SQL with comments and literals scrubbed while preserving line breaks, making keyword-based safety checks less prone to false matches.
func CommentlessText ¶
CommentlessText returns SQL with comments scrubbed but literal contents kept, which supports checks that need string patterns such as LIKE wildcards.
func HasTokenSequence ¶
func Mutating ¶
Mutating reports whether any statement appears to change database state. Read-like statement prefixes are allowed; everything else is treated conservatively as a mutation.
func Read ¶
Read loads SQL from Source, rejecting ambiguous input combinations so callers do not accidentally execute different text than intended.
func Statements ¶
Statements splits SQL into executable statements without line metadata.
Types ¶
type Danger ¶
Danger describes a SQL pattern that is unsafe enough to block in readonly or guarded execution modes.
type Statement ¶
Statement contains one SQL statement and the one-based line where it starts.
func StatementsWithLine ¶
StatementsWithLine splits SQL on semicolons that are outside quoted strings and comments, preserving the starting line for diagnostics.