Documentation
¶
Overview ¶
Package builder assembles reader SQL from resolved views, selectors, relations, partitions, templates, and dialect capabilities.
Index ¶
- func MergeViewControlsWithSelector(controls *spec.ViewControls, selector *xstate.Selector) *spec.ViewControls
- func MissingPreparedRelationRootSQL(component *spec.Component, relation *data.Relation) error
- func NonWindowControls(controls *spec.ViewControls, selector *xstate.Selector) *spec.ViewControls
- func NonWindowSelector(selector *xstate.Selector) *xstate.Selector
- func NormalizePreparedRelationSQL(sqlText string) string
- func PreparedRelationNonWindowTokens(component *spec.Component) []string
- func PreparedRelationSQL(component *spec.Component, relation *data.Relation, rootNonWindowSQL string) (string, error)
- type Builder
- func (b *Builder) Build(ctx context.Context, opts ...BuilderOption) (*cache.ParmetrizedQuery, error)
- func (b *Builder) CacheSQL(ctx context.Context, opts ...BuilderOption) (*cache.ParmetrizedQuery, error)
- func (b *Builder) ProjectionSource(sqlText string) (string, error)
- func (b *Builder) QueryMatcher(ctx context.Context, query *cache.ParmetrizedQuery, opts ...BuilderOption) (*cache.ParmetrizedQuery, error)
- func (b *Builder) ShapeBound(query *cache.ParmetrizedQuery, opts ...BuilderOption) (*cache.ParmetrizedQuery, error)
- type BuilderOption
- func WithBuilderBinder(binder xhandler.Binder) BuilderOption
- func WithBuilderComponent(component *spec.Component) BuilderOption
- func WithBuilderCompositeArgs(columns []string, rows [][]interface{}) BuilderOption
- func WithBuilderControls(controls *spec.ViewControls) BuilderOption
- func WithBuilderCriteriaCompiler(compiler *criteria.Compiler) BuilderOption
- func WithBuilderDialect(dialect *info.Dialect) BuilderOption
- func WithBuilderExcludePagination(exclude bool) BuilderOption
- func WithBuilderInput(input reflect.Value) BuilderOption
- func WithBuilderMatcher(by string, in []any) BuilderOption
- func WithBuilderParameterResolver(resolver sqlx.ParameterResolver) BuilderOption
- func WithBuilderParentQuery(query *cache.ParmetrizedQuery) BuilderOption
- func WithBuilderParentSelector(selector *xstate.Selector) BuilderOption
- func WithBuilderPartition(partition *PartitionInput) BuilderOption
- func WithBuilderPositionalArgs(args []any) BuilderOption
- func WithBuilderProjection(columns []string) BuilderOption
- func WithBuilderRelation(relation *data.Relation) BuilderOption
- func WithBuilderSQL(sqlText string) BuilderOption
- func WithBuilderSelector(selector *xstate.Selector) BuilderOption
- func WithBuilderSelectorPolicy(policy *spec.Selector) BuilderOption
- func WithBuilderSkipRelationFilter(skip bool) BuilderOption
- func WithBuilderSource(source *spec.ViewSource) BuilderOption
- func WithBuilderTemplate(evaluator sqltemplate.Evaluator) BuilderOption
- func WithBuilderView(view *data.View) BuilderOption
- type PartitionInput
- type PreparedRelationBinder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MergeViewControlsWithSelector ¶
func MergeViewControlsWithSelector(controls *spec.ViewControls, selector *xstate.Selector) *spec.ViewControls
func NonWindowControls ¶
func NonWindowControls(controls *spec.ViewControls, selector *xstate.Selector) *spec.ViewControls
NonWindowControls returns the merged controls for the root SQL with the pagination window stripped so derived SQL can safely wrap the full parent query through $View.NonWindowSQL.
func PreparedRelationSQL ¶
func PreparedRelationSQL(component *spec.Component, relation *data.Relation, rootNonWindowSQL string) (string, error)
PreparedRelationSQL resolves the authored SQL text for a prepared relation query from the derived runtime relation, including $View.NonWindowSQL expansion. Placeholder binding stays outside this owner: route preparation still binds named placeholders against the already-bound input after this relation-owned SQL text is resolved.
Types ¶
type Builder ¶
type Builder struct{}
Builder assembles reader queries from resolved view, selector, relation, template, partition, and invocation metadata.
func NewBuilder ¶
func NewBuilder() *Builder
func (*Builder) Build ¶
func (b *Builder) Build(ctx context.Context, opts ...BuilderOption) (*cache.ParmetrizedQuery, error)
func (*Builder) CacheSQL ¶
func (b *Builder) CacheSQL(ctx context.Context, opts ...BuilderOption) (*cache.ParmetrizedQuery, error)
func (*Builder) ProjectionSource ¶
ProjectionSource prepares relation markers for static projection inspection. The same source owner expands them with invocation values during Build. It neither evaluates input templates nor changes the authored view SQL.
func (*Builder) QueryMatcher ¶
func (b *Builder) QueryMatcher(ctx context.Context, query *cache.ParmetrizedQuery, opts ...BuilderOption) (*cache.ParmetrizedQuery, error)
QueryMatcher describes relation-local key/window semantics for the exact query executed by the reader. Indexed warmup may use CacheSQL separately; this matcher remains valid for ordinary sqlx lazy-cache replay even when an authored source has no explicit removable parent-key macro.
func (*Builder) ShapeBound ¶
func (b *Builder) ShapeBound(query *cache.ParmetrizedQuery, opts ...BuilderOption) (*cache.ParmetrizedQuery, error)
ShapeBound applies view selector policy to SQL whose authored placeholders are already bound. It preserves the existing argument order and is used by ordinary output relations that expand parent SQL before selector shaping.
type BuilderOption ¶
type BuilderOption func(*builderOptions)
func WithBuilderBinder ¶
func WithBuilderBinder(binder xhandler.Binder) BuilderOption
WithBuilderBinder supplies the invocation-scoped DI binder used by compiled SQL parameter contracts. The builder never retains it beyond Build.
func WithBuilderComponent ¶
func WithBuilderComponent(component *spec.Component) BuilderOption
func WithBuilderCompositeArgs ¶
func WithBuilderCompositeArgs(columns []string, rows [][]interface{}) BuilderOption
func WithBuilderControls ¶
func WithBuilderControls(controls *spec.ViewControls) BuilderOption
func WithBuilderCriteriaCompiler ¶
func WithBuilderCriteriaCompiler(compiler *criteria.Compiler) BuilderOption
func WithBuilderDialect ¶
func WithBuilderDialect(dialect *info.Dialect) BuilderOption
func WithBuilderExcludePagination ¶
func WithBuilderExcludePagination(exclude bool) BuilderOption
func WithBuilderInput ¶
func WithBuilderInput(input reflect.Value) BuilderOption
func WithBuilderMatcher ¶
func WithBuilderMatcher(by string, in []any) BuilderOption
func WithBuilderParameterResolver ¶
func WithBuilderParameterResolver(resolver sqlx.ParameterResolver) BuilderOption
WithBuilderParameterResolver supplies invocation-scoped named SQL values. SQLX remains the sole owner of placeholder parsing and argument ordering.
func WithBuilderParentQuery ¶
func WithBuilderParentQuery(query *cache.ParmetrizedQuery) BuilderOption
WithBuilderParentQuery supplies the invocation-scoped non-window query exposed through $View.NonWindowSQL in a compiled child-view template.
func WithBuilderParentSelector ¶
func WithBuilderParentSelector(selector *xstate.Selector) BuilderOption
WithBuilderParentSelector supplies parent invocation state that is not part of sqlx's parametrized query, currently the authored page number.
func WithBuilderPartition ¶
func WithBuilderPartition(partition *PartitionInput) BuilderOption
func WithBuilderPositionalArgs ¶
func WithBuilderPositionalArgs(args []any) BuilderOption
func WithBuilderProjection ¶
func WithBuilderProjection(columns []string) BuilderOption
func WithBuilderRelation ¶
func WithBuilderRelation(relation *data.Relation) BuilderOption
func WithBuilderSQL ¶
func WithBuilderSQL(sqlText string) BuilderOption
func WithBuilderSelector ¶
func WithBuilderSelector(selector *xstate.Selector) BuilderOption
func WithBuilderSelectorPolicy ¶
func WithBuilderSelectorPolicy(policy *spec.Selector) BuilderOption
WithBuilderSelectorPolicy supplies immutable per-view selector policy. When omitted, the builder derives it from WithBuilderComponent when available.
func WithBuilderSkipRelationFilter ¶
func WithBuilderSkipRelationFilter(skip bool) BuilderOption
func WithBuilderSource ¶
func WithBuilderSource(source *spec.ViewSource) BuilderOption
WithBuilderSource supplies immutable SQL source metadata as one unit. It is preferred over passing SQL text and controls separately when a view source is available.
func WithBuilderTemplate ¶
func WithBuilderTemplate(evaluator sqltemplate.Evaluator) BuilderOption
WithBuilderTemplate injects the precompiled root SQL-template evaluator.
func WithBuilderView ¶
func WithBuilderView(view *data.View) BuilderOption
WithBuilderView supplies the canonical static/runtime-separated view model. SQL construction reads static source/column/selector metadata only.
type PartitionInput ¶
PartitionInput is the invocation-local SQL build input produced by a partitioner. Static partitioner identity/concurrency remain view metadata.
func (*PartitionInput) Clone ¶
func (p *PartitionInput) Clone() *PartitionInput
type PreparedRelationBinder ¶
type PreparedRelationBinder struct {
Component *spec.Component
Relation *data.Relation
RootNonWindowSQL string
RootArgs []any
ParameterResolver sqlx.ParameterResolver
}
PreparedRelationBinder owns the route-preparation binding of one prepared relation query. It keeps the relation/query-specific state together so route preparation delegates relation SQL assembly instead of open-coding token scanning and root-arg stitching in the runtime shell.