query

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Embed

type Embed struct {
	Relation string
	Items    []SelectItem
}

Embed describes a nested relation projection. Populated in Phase 4.

type FilterGroup

type FilterGroup struct {
	Op    LogicalOp
	Nodes []FilterNode
}

FilterGroup combines child nodes under a logical connective.

type FilterNode

type FilterNode interface {
	// contains filtered or unexported methods
}

FilterNode is a node in the filter tree: either a Predicate (leaf) or a FilterGroup (branch). The sealing method keeps the union closed to this package.

type LogicalOp

type LogicalOp int

LogicalOp is a logical connective for FilterGroup.

const (
	LogicalAnd LogicalOp = iota + 1
	LogicalOr
)

func (LogicalOp) String

func (op LogicalOp) String() string

type Operator

type Operator int

Operator is a PostgREST-style filter operator.

const (
	OpEq Operator = iota + 1
	OpNeq
	OpGt
	OpGte
	OpLt
	OpLte
	OpLike
	OpILike
	OpIn
	OpIs
	// OpCs / OpCd are JSON / array containment, matching PostgREST.
	// Backed by Postgres `@>` / `<@` for jsonb and array columns, and
	// MySQL JSON_CONTAINS for json columns. Other column types are
	// rejected at SQL build time.
	OpCs
	OpCd
)

func (Operator) String

func (op Operator) String() string

type OrderItem

type OrderItem struct {
	Column string
	Desc   bool
}

OrderItem is one element of an order clause.

type Predicate

type Predicate struct {
	Column string
	Op     Operator
	Value  string
	Not    bool
}

Predicate is a leaf filter expression of the form "column op value". For OpIn the Value is the comma-separated list with the surrounding parentheses already stripped. For OpIs the Value is one of "null", "true", "false".

type Query

type Query struct {
	Select []SelectItem
	Filter FilterNode
	Order  []OrderItem
	Limit  *int
	Offset *int
}

Query is the parsed form of a single request's query parameters. It carries only syntactic shape; identifier validation against the schema and limit clamping are the caller's responsibility.

func Parse

func Parse(values url.Values) (Query, error)

Parse converts url.Values into a Query. It only enforces syntactic shape: identifier validation against the schema and limit clamping are the caller's responsibility.

Reserved keys: select, order, limit, offset, and, or. Every other key is treated as a column filter; multiple values for the same column are combined with logical AND, the same way multiple distinct filter keys are combined.

type SelectItem

type SelectItem struct {
	Column string
	Alias  string
	Embed  *Embed
}

SelectItem is one element of a select clause. Phase 3 fills only Column (a flat column name or "*"); Alias and Embed are reserved for Phase 4 relation embedding.

Jump to

Keyboard shortcuts

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