ast

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggFunc added in v0.3.0

type AggFunc int
const (
	AggSum AggFunc = iota
	AggAvg
	AggMin
	AggMax
	AggCount
)

type AggregateExpr added in v0.3.0

type AggregateExpr struct {
	Func         AggFunc
	Column       string
	Alias        string
	Distinct     bool
	CoalesceZero bool
}

type ComparisonNode

type ComparisonNode struct {
	Column string
	Op     Operator
	Value  any
	Values []any
}

type Direction

type Direction int
const (
	Asc Direction = iota
	Desc
)

type JoinNode added in v0.5.0

type JoinNode struct {
	Table string   // joined table
	Type  JoinType // INNER / LEFT
	On    string   // raw, already-qualified ON expression, e.g. `"orders"."user_id" = "users"."id"`
}

JoinNode is a single JOIN clause in a projection SELECT.

type JoinType added in v0.5.0

type JoinType int

JoinType is the kind of SQL join used in a projection.

const (
	JoinInner JoinType = iota
	JoinLeft
)

type LogicalOp

type LogicalOp int
const (
	LogicalAnd LogicalOp = iota
	LogicalOr
	LogicalNot
)

type NullsOrder added in v0.5.0

type NullsOrder int

NullsOrder controls placement of NULL values within an ORDER BY clause. NullsDefault omits the clause and lets the database apply its default (Postgres: NULLS LAST for ASC, NULLS FIRST for DESC; SQLite: NULLS FIRST for ASC, NULLS LAST for DESC).

const (
	NullsDefault NullsOrder = iota
	NullsFirst
	NullsLast
)

type Operator

type Operator int
const (
	OpEq Operator = iota
	OpNEQ
	OpGT
	OpGTE
	OpLT
	OpLTE
	OpLike
	OpILike
	OpIn
	OpNotIn
	OpBetween
	OpIsNull
	OpIsNotNull
)

type OrderByExpr

type OrderByExpr struct {
	Column    string
	Direction Direction
	Nulls     NullsOrder
}

type PartitionLimit added in v0.5.0

type PartitionLimit struct {
	PartitionBy string        // foreign-key column to partition by
	OrderBy     []OrderByExpr // ordering within each partition (defaults to PK at the call site)
	Limit       int           // rows kept per partition
}

PartitionLimit requests a per-partition row cap rendered with a window function (ROW_NUMBER() OVER (PARTITION BY ... ORDER BY ...)). It is used by the relationship loader to apply Include Limit(n) per parent rather than across the whole batch. When set, the emitter wraps the base SELECT and keeps only rows whose row number is <= Limit.

type QueryType

type QueryType int
const (
	QuerySelect QueryType = iota
	QueryCount
	QueryExists
)

type SelectNode

type SelectNode struct {
	Table          string
	Columns        []string
	Where          *WhereClause
	OrderBy        []OrderByExpr
	Limit          *int
	Offset         *int
	Type           QueryType
	GroupBy        []string
	Having         *WhereClause
	Aggregates     []AggregateExpr
	PartitionLimit *PartitionLimit
	Distinct       bool
	Joins          []JoinNode
}

type WhereClause

type WhereClause struct {
	Comparison *ComparisonNode
	LogicalOp  LogicalOp
	Children   []WhereClause
	Raw        *string
	RawArgs    []any
}

Jump to

Keyboard shortcuts

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