queryops

package
v0.158.4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package queryops derives bounded, previewable TugQL operations without running a query or resolving any source. It only transforms DALgo's typed AST and returns a canonical TugQL document for the caller to inspect or submit.

Index

Constants

View Source
const MaxPreviewRows = 500

Variables

View Source
var (
	ErrUnsupported   = errors.New("query derivation is unsupported")
	ErrInvalidColumn = errors.New("query derivation has an invalid or ambiguous column")
)

Functions

func AggregateAlias

func AggregateAlias(function, column string, reserved []string) string

AggregateAlias produces a readable stable identifier, suffixing collisions case-insensitively. Explicit caller aliases are validated separately.

Types

type AggregateTerm

type AggregateTerm struct{ Column, Function, Alias string }

AggregateTerm names one explicit aggregate over an original projected column. COUNT(*) is represented separately by count; COUNT terms count non-null cells.

type Preview

type Preview struct {
	TugQL         string
	OutputColumns []string
	Scope         Scope
}

Preview is the exact validated TugQL document and its resulting projection.

func DeriveGroup

func DeriveGroup(originalTugQL string, groupColumns []string, count bool, scope Scope) (Preview, error)

DeriveGroup creates a bounded query preview grouped by selected projected columns. Count adds only an explicit COUNT(*) output; no other aggregates are inferred. Empty groupColumns is refused.

func DeriveGroupAggregates

func DeriveGroupAggregates(originalTugQL string, keys []string, count bool, terms []AggregateTerm, scope Scope) (Preview, error)

DeriveGroupAggregates preserves the chosen input scope and emits the exact, ordered key, optional COUNT(*), and explicit measure projection. Missing measure aliases use readable, collision-safe defaults; caller inputs stay intact.

func DeriveSort

func DeriveSort(originalTugQL string, terms []SortTerm, scope Scope) (Preview, error)

DeriveSort creates a bounded query preview ordered by selected projected columns. It deliberately replaces the query's final ordering and output cap.

type Scope

type Scope uint8

Scope identifies which rows a server operation transforms.

const (
	MatchingSource Scope = iota + 1
	OriginalOutput
)

type SortTerm

type SortTerm struct {
	Column     string
	Descending bool
}

SortTerm selects one projected column and direction. Earlier terms have higher priority; equal-key ordering and collation follow the query backend's tie, collation, and null semantics unless callers add explicit tie keys.

Jump to

Keyboard shortcuts

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