ast

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package ast provides abstract syntax tree representations for SQLite SQL statements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alias

type Alias struct {
	Expr  Expression
	Alias string
}

Alias represents an expression with an alias.

func (*Alias) String

func (a *Alias) String() string

type BetweenExpression

type BetweenExpression struct {
	Expr  Expression
	Not   bool
	Start Expression
	End   Expression
}

BetweenExpression represents a BETWEEN expression.

func (*BetweenExpression) String

func (b *BetweenExpression) String() string

type BinaryExpression

type BinaryExpression struct {
	Left     Expression
	Operator string
	Right    Expression
}

BinaryExpression represents a binary operation.

func (*BinaryExpression) String

func (b *BinaryExpression) String() string

type BindParameter

type BindParameter struct {
	Value string // ?1, @name, :param
}

BindParameter represents a parameter in a prepared statement.

func (*BindParameter) String

func (b *BindParameter) String() string

type BlobLiteral

type BlobLiteral struct {
	Value string // Hex string
}

BlobLiteral represents a BLOB literal in SQLite (X'HEXSTRING').

func (*BlobLiteral) String

func (b *BlobLiteral) String() string

type BooleanLiteral

type BooleanLiteral struct {
	Value bool
}

BooleanLiteral represents a boolean value in SQLite (0 or 1).

func (*BooleanLiteral) String

func (b *BooleanLiteral) String() string

type CaseExpression

type CaseExpression struct {
	Value       Expression
	WhenClauses []WhenClause
	ElseClause  Expression
}

CaseExpression represents a CASE expression.

func (*CaseExpression) String

func (c *CaseExpression) String() string

type ColumnConstraint

type ColumnConstraint struct {
	Type string // "PRIMARY KEY", "NOT NULL", etc.
	Expr Expression
}

ColumnConstraint represents a constraint on a column.

func (*ColumnConstraint) String

func (c *ColumnConstraint) String() string

type ColumnDefinition

type ColumnDefinition struct {
	Name        Expression
	Type        string
	Constraints []ColumnConstraint
}

ColumnDefinition represents a column definition in a CREATE TABLE statement.

func (*ColumnDefinition) String

func (c *ColumnDefinition) String() string

type CreateTableStatement

type CreateTableStatement struct {
	TableName   Expression
	ColumnDefs  []ColumnDefinition
	Constraints []TableConstraint
	IfNotExists bool
}

CreateTableStatement represents a CREATE TABLE statement.

func (*CreateTableStatement) String

func (c *CreateTableStatement) String() string

type DeleteStatement

type DeleteStatement struct {
	TableName Expression
	Where     Expression
}

DeleteStatement represents a DELETE statement.

func (*DeleteStatement) String

func (d *DeleteStatement) String() string

type Expression

type Expression interface {
	Node
	// contains filtered or unexported methods
}

Expression is a value-producing construct.

type FloatLiteral

type FloatLiteral struct {
	Value float64
}

FloatLiteral represents a floating point literal.

func (*FloatLiteral) String

func (f *FloatLiteral) String() string

type FunctionCall

type FunctionCall struct {
	Name      string
	Arguments []Expression
}

FunctionCall represents a function call.

func (*FunctionCall) String

func (f *FunctionCall) String() string

type Identifier

type Identifier struct {
	Value  string
	Quoted bool
}

Identifier represents a table or column name.

func (*Identifier) String

func (i *Identifier) String() string

type InExpression

type InExpression struct {
	Left      Expression
	Not       bool
	ValueList []Expression
}

InExpression represents an IN expression.

func (*InExpression) String

func (i *InExpression) String() string

type InsertStatement

type InsertStatement struct {
	TableName Expression
	Columns   []Expression
	Values    [][]Expression
}

InsertStatement represents an INSERT statement.

func (*InsertStatement) String

func (i *InsertStatement) String() string

type IntegerLiteral

type IntegerLiteral struct {
	Value int64
}

IntegerLiteral represents an integer literal.

func (*IntegerLiteral) String

func (i *IntegerLiteral) String() string

type IsExpression

type IsExpression struct {
	Left  Expression
	Not   bool
	Right Expression
}

IsExpression represents an IS or IS NOT expression.

func (*IsExpression) String

func (i *IsExpression) String() string

type JoinClause

type JoinClause struct {
	JoinType  string // "INNER", "LEFT", "RIGHT", etc.
	TableName Expression
	Condition Expression
}

JoinClause represents a JOIN clause in a SELECT statement.

func (*JoinClause) String

func (j *JoinClause) String() string

type LikeExpression

type LikeExpression struct {
	Left    Expression
	Not     bool
	Pattern Expression
	Escape  Expression
}

LikeExpression represents a LIKE expression.

func (*LikeExpression) String

func (l *LikeExpression) String() string

type Literal

type Literal interface {
	Expression
	// contains filtered or unexported methods
}

Literal represents a literal value in SQL (string, number, etc).

type Node

type Node interface {
	String() string
}

Node is the interface that all AST nodes implement.

type NullLiteral

type NullLiteral struct{}

NullLiteral represents a NULL value.

func (*NullLiteral) String

func (n *NullLiteral) String() string

type OrderByClause

type OrderByClause struct {
	Expr      Expression
	Direction string // "ASC" or "DESC"
}

OrderByClause represents an ORDER BY clause in a SELECT statement.

func (*OrderByClause) String

func (o *OrderByClause) String() string

type Parenthesis

type Parenthesis struct {
	Expr Expression
}

Parenthesis represents an expression in parentheses.

func (*Parenthesis) String

func (p *Parenthesis) String() string

type Program

type Program struct {
	Statements []Statement
}

Program represents a complete SQL program, which is a list of statements.

func (*Program) String

func (p *Program) String() string

type QualifiedStar

type QualifiedStar struct {
	Table Expression
}

QualifiedStar represents a table.* in a SELECT statement.

func (*QualifiedStar) String

func (q *QualifiedStar) String() string

type SelectStatement

type SelectStatement struct {
	Columns     []Expression
	TableName   Expression
	Where       Expression
	OrderBy     []OrderByClause
	GroupBy     []Expression
	Having      Expression
	Limit       Expression
	Offset      Expression
	JoinClauses []JoinClause
}

SelectStatement represents a SELECT query.

func (*SelectStatement) String

func (s *SelectStatement) String() string

type SetPair

type SetPair struct {
	Column Expression
	Value  Expression
}

SetPair represents a column=value pair in an UPDATE statement.

func (*SetPair) String

func (s *SetPair) String() string

type Star

type Star struct{}

Star represents a * in a SELECT statement.

func (*Star) String

func (s *Star) String() string

type Statement

type Statement interface {
	Node
	// contains filtered or unexported methods
}

Statement is a complete SQL statement.

type StringLiteral

type StringLiteral struct {
	Value string
}

StringLiteral represents a string literal.

func (*StringLiteral) String

func (s *StringLiteral) String() string

type TableConstraint

type TableConstraint struct {
	Type           string // "PRIMARY KEY", "UNIQUE", "FOREIGN KEY", etc.
	Columns        []Expression
	ForeignTable   Expression
	ForeignColumns []Expression
}

TableConstraint represents a table-level constraint.

func (*TableConstraint) String

func (t *TableConstraint) String() string

type UnaryExpression

type UnaryExpression struct {
	Operator string
	Right    Expression
}

UnaryExpression represents a unary operation.

func (*UnaryExpression) String

func (u *UnaryExpression) String() string

type UpdateStatement

type UpdateStatement struct {
	TableName Expression
	SetPairs  []SetPair
	Where     Expression
}

UpdateStatement represents an UPDATE statement.

func (*UpdateStatement) String

func (u *UpdateStatement) String() string

type WhenClause

type WhenClause struct {
	Condition Expression
	Result    Expression
}

WhenClause represents a WHEN ... THEN clause in a CASE expression.

func (*WhenClause) String

func (w *WhenClause) String() string

Jump to

Keyboard shortcuts

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