Documentation
¶
Overview ¶
Package ast defines the abstract syntax tree types for AQL (Aha Query Language).
Index ¶
- type AggregateFunc
- type AggregateType
- type Assignment
- type BinaryExpr
- type CompareExpr
- type CompareOp
- type DeleteStatement
- type EntityType
- type Expr
- type FieldRef
- type FromClause
- type FunctionExpr
- type GroupByClause
- type HavingClause
- type InsertStatement
- type JoinClause
- type JoinType
- type LiteralExpr
- type LogicalOp
- type NotExpr
- type OrderByClause
- type ParenExpr
- type Position
- type Query
- type SelectClause
- type SelectItem
- type SortDirection
- type Statement
- type SubqueryExpr
- type UpdateStatement
- type Value
- type ValueType
- type WhereClause
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregateFunc ¶
type AggregateFunc struct {
Func AggregateType
Field *FieldRef // nil for COUNT(*)
Distinct bool // COUNT(DISTINCT field)
Pos Position
}
AggregateFunc represents an aggregate function call.
func (AggregateFunc) String ¶
func (a AggregateFunc) String() string
String returns the string representation of the aggregate function.
type AggregateType ¶
type AggregateType string
AggregateType represents the type of aggregate function.
const ( AggCount AggregateType = "COUNT" AggSum AggregateType = "SUM" AggAvg AggregateType = "AVG" AggMin AggregateType = "MIN" AggMax AggregateType = "MAX" )
Aggregate function types.
type Assignment ¶
Assignment represents a field = value assignment in UPDATE.
type BinaryExpr ¶
type BinaryExpr struct {
Left Expr
Op LogicalOp
Right Expr
// contains filtered or unexported fields
}
BinaryExpr represents a binary logical expression (AND/OR).
func NewBinaryExpr ¶
func NewBinaryExpr(left Expr, op LogicalOp, right Expr, pos Position) *BinaryExpr
NewBinaryExpr creates a new binary expression.
func (*BinaryExpr) Pos ¶
func (e *BinaryExpr) Pos() Position
func (*BinaryExpr) String ¶
func (e *BinaryExpr) String() string
type CompareExpr ¶
type CompareExpr struct {
Field FieldRef
Op CompareOp
Value *Value // nil for IS NULL/IS NOT NULL
// contains filtered or unexported fields
}
CompareExpr represents a comparison expression.
func NewCompareExpr ¶
func NewCompareExpr(field FieldRef, op CompareOp, value *Value, pos Position) *CompareExpr
NewCompareExpr creates a new comparison expression.
func (*CompareExpr) Pos ¶
func (e *CompareExpr) Pos() Position
func (*CompareExpr) String ¶
func (e *CompareExpr) String() string
type CompareOp ¶
type CompareOp string
CompareOp represents a comparison operator.
const ( OpEQ CompareOp = "=" OpNE CompareOp = "!=" OpLT CompareOp = "<" OpLE CompareOp = "<=" OpGT CompareOp = ">" OpGE CompareOp = ">=" OpIN CompareOp = "IN" OpNotIn CompareOp = "NOT IN" OpContains CompareOp = "CONTAINS" OpLike CompareOp = "LIKE" OpIsNull CompareOp = "IS NULL" OpIsNotNull CompareOp = "IS NOT NULL" )
Comparison operators.
type DeleteStatement ¶
type DeleteStatement struct {
Entity EntityType
Where *WhereClause
Pos Position
}
DeleteStatement represents a DELETE statement.
type EntityType ¶
type EntityType string
EntityType represents the type of Aha entity being queried.
const ( EntityComments EntityType = "comments" EntityEpics EntityType = "epics" EntityFeatures EntityType = "features" EntityGoals EntityType = "goals" EntityIdeas EntityType = "ideas" EntityReleases EntityType = "releases" EntityRequirements EntityType = "requirements" EntityInitiatives EntityType = "initiatives" EntityProducts EntityType = "products" EntityTags EntityType = "tags" EntityUsers EntityType = "users" )
Valid entity types.
func (EntityType) IsValid ¶
func (e EntityType) IsValid() bool
IsValid returns true if the entity type is valid.
type FieldRef ¶
type FieldRef struct {
Name string
Qualifier string // optional entity qualifier (e.g., "features.name")
Pos Position
}
FieldRef references a field, possibly with a table/entity qualifier.
type FromClause ¶
type FromClause struct {
Entity EntityType
Alias string // optional table alias (e.g., FROM features AS f)
Pos Position
}
FromClause specifies the entity type to query.
type FunctionExpr ¶
FunctionExpr represents a function call in an expression.
func NewFunctionExpr ¶
func NewFunctionExpr(name string, args []Expr, pos Position) *FunctionExpr
NewFunctionExpr creates a new function expression.
func (*FunctionExpr) Pos ¶
func (e *FunctionExpr) Pos() Position
func (*FunctionExpr) String ¶
func (e *FunctionExpr) String() string
type GroupByClause ¶
GroupByClause specifies the grouping fields.
type HavingClause ¶
HavingClause contains the filter expression for grouped results.
type InsertStatement ¶
type InsertStatement struct {
Entity EntityType
Columns []string
Values []Value
Pos Position
}
InsertStatement represents an INSERT statement.
type JoinClause ¶
type JoinClause struct {
Type JoinType
Entity EntityType
Alias string // optional table alias
Condition Expr // ON condition
Pos Position
}
JoinClause represents a JOIN between entities.
type LiteralExpr ¶
type LiteralExpr struct {
Value Value
// contains filtered or unexported fields
}
LiteralExpr represents a literal value expression.
func NewLiteralExpr ¶
func NewLiteralExpr(value Value, pos Position) *LiteralExpr
NewLiteralExpr creates a new literal expression.
func (*LiteralExpr) Pos ¶
func (e *LiteralExpr) Pos() Position
func (*LiteralExpr) String ¶
func (e *LiteralExpr) String() string
type NotExpr ¶
type NotExpr struct {
Expr Expr
// contains filtered or unexported fields
}
NotExpr represents a NOT expression.
func NewNotExpr ¶
NewNotExpr creates a new NOT expression.
type OrderByClause ¶
type OrderByClause struct {
Field FieldRef
Dir SortDirection
Pos Position
}
OrderByClause specifies the sort order.
type ParenExpr ¶
type ParenExpr struct {
Expr Expr
// contains filtered or unexported fields
}
ParenExpr represents a parenthesized expression.
func NewParenExpr ¶
NewParenExpr creates a new parenthesized expression.
type Position ¶
type Position struct {
Offset int // byte offset
Line int // 1-based line number
Column int // 1-based column number
}
Position represents a position in the source query.
type Query ¶
type Query struct {
Select *SelectClause
From *FromClause
Joins []*JoinClause
Where *WhereClause
GroupBy *GroupByClause
Having *HavingClause
OrderBy *OrderByClause
Limit *int
}
Query represents a complete AQL query.
func (*Query) HasAggregates ¶
HasAggregates returns true if the query contains aggregate functions.
type SelectClause ¶
type SelectClause struct {
Items []SelectItem
Distinct bool
Pos Position
}
SelectClause specifies which fields or expressions to return.
type SelectItem ¶
type SelectItem struct {
// Field is set for simple field references
Field *FieldRef
// Aggregate is set for aggregate functions
Aggregate *AggregateFunc
// Star is true for SELECT *
Star bool
// Alias is the optional AS alias
Alias string
Pos Position
}
SelectItem represents a single item in a SELECT clause.
func (SelectItem) OutputName ¶
func (s SelectItem) OutputName() string
OutputName returns the name to use for this item in results.
func (SelectItem) String ¶
func (s SelectItem) String() string
String returns the string representation of the select item.
type SortDirection ¶
type SortDirection string
SortDirection specifies the sort order.
const ( SortAsc SortDirection = "ASC" SortDesc SortDirection = "DESC" )
Sort directions.
type Statement ¶
type Statement interface {
// contains filtered or unexported methods
}
Statement represents any AQL statement (query or mutation).
type SubqueryExpr ¶
type SubqueryExpr struct {
Query *Query
// contains filtered or unexported fields
}
SubqueryExpr represents a subquery expression (a nested query).
func NewSubqueryExpr ¶
func NewSubqueryExpr(query *Query, pos Position) *SubqueryExpr
NewSubqueryExpr creates a new subquery expression.
func (*SubqueryExpr) Pos ¶
func (e *SubqueryExpr) Pos() Position
func (*SubqueryExpr) String ¶
func (e *SubqueryExpr) String() string
type UpdateStatement ¶
type UpdateStatement struct {
Entity EntityType
Assignments []Assignment
Where *WhereClause
Pos Position
}
UpdateStatement represents an UPDATE statement.
type Value ¶
type Value struct {
Type ValueType
Raw string // original string representation
// Typed values (only one is set based on Type)
String string
Int int64
Float float64
Bool bool
Time time.Time
Duration time.Duration
Strings []string // for IN clauses
Subquery *Query // for subquery expressions
}
Value represents a literal value in an expression.
type ValueType ¶
type ValueType int
ValueType represents the type of a value.
type WhereClause ¶
WhereClause contains the filter expression.