syntax

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindMatchingParen

func FindMatchingParen(input string, openIndex int) int

FindMatchingParen finds the matching closing paren for an opening paren index.

func FindTopLevelKeyword

func FindTopLevelKeyword(input, keyword string) int

FindTopLevelKeyword finds a keyword outside nested structures.

func SplitTopLevelCSV

func SplitTopLevelCSV(input string) []string

SplitTopLevelCSV splits a comma-separated string while ignoring nested commas.

func StripIdentifier

func StripIdentifier(input string) string

StripIdentifier removes surrounding quote markers from a simple identifier.

func TrimStatement

func TrimStatement(sql string) string

TrimStatement removes surrounding whitespace and a trailing semicolon.

Types

type Assignment

type Assignment struct {
	Column string
	Value  string
}

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

type DeleteStatement struct {
	Table string
	Where string
}

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 Join

type Join struct {
	Kind  string
	Table string
	On    string
}

Join is a parsed join clause.

type LimitClause

type LimitClause struct {
	Offset *int
	Count  int
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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