Documentation
¶
Index ¶
- func FindMatchingParen(input string, openIndex int) int
- func FindTopLevelKeyword(input, keyword string) int
- func SplitTopLevelCSV(input string) []string
- func StripIdentifier(input string) string
- func TrimStatement(sql string) string
- type Assignment
- type ConflictClause
- type ConflictStyle
- type DeleteStatement
- type InsertStatement
- type Join
- type LimitClause
- type RawStatement
- type SelectStatement
- type Statement
- type UpdateStatement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindMatchingParen ¶
FindMatchingParen finds the matching closing paren for an opening paren index.
func FindTopLevelKeyword ¶
FindTopLevelKeyword finds a keyword outside nested structures.
func SplitTopLevelCSV ¶
SplitTopLevelCSV splits a comma-separated string while ignoring nested commas.
func StripIdentifier ¶
StripIdentifier removes surrounding quote markers from a simple identifier.
func TrimStatement ¶
TrimStatement removes surrounding whitespace and a trailing semicolon.
Types ¶
type Assignment ¶
Assignment is a parsed assignment pair.
type ConflictClause ¶
type ConflictClause struct {
Style ConflictStyle
TargetColumns []string
Assignments []Assignment
}
ConflictClause is a parsed upsert clause.
type ConflictStyle ¶
type ConflictStyle string
ConflictStyle identifies the source upsert form.
const ( // ConflictStyleMySQL represents ON DUPLICATE KEY UPDATE. ConflictStyleMySQL ConflictStyle = "mysql" // ConflictStylePostgres represents ON CONFLICT ... DO UPDATE. ConflictStylePostgres ConflictStyle = "postgres" )
type DeleteStatement ¶
DeleteStatement is a minimal DELETE AST.
type InsertStatement ¶
type InsertStatement struct {
Table string
Columns []string
Values []string
Conflict *ConflictClause
}
InsertStatement is a minimal INSERT AST.
type LimitClause ¶
LimitClause is a parsed LIMIT/OFFSET pair.
type RawStatement ¶
type RawStatement struct {
SQL string
}
RawStatement preserves SQL that is not yet structurally parsed.
type SelectStatement ¶
type SelectStatement struct {
Columns []string
From string
Joins []Join
Where string
OrderBy []string
Limit *LimitClause
}
SelectStatement is a minimal SELECT AST.
type Statement ¶
type Statement interface {
// contains filtered or unexported methods
}
Statement is the syntax-layer statement node.
type UpdateStatement ¶
type UpdateStatement struct {
Table string
Assignments []Assignment
Where string
}
UpdateStatement is a minimal UPDATE AST.