macro

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package macro parses and expands Datly SQL macros such as ParentJoinOn, ParentKey, and parent NonWindowSQL access.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandNonWindowSQL

func ExpandNonWindowSQL(sql string, nonWindowSQL string, aliases ...string) (string, int)

ExpandNonWindowSQL replaces $View.NonWindowSQL and any explicitly named $View.<ParentViewName>.NonWindowSQL aliases with the supplied non-window SQL, returning the rewritten text and the number of replaced occurrences.

func ExpandParentKeyCalls

func ExpandParentKeyCalls(sql string, dialect *info.Dialect, scalarValues []any, compositeRows [][]interface{}) (string, []any, int, error)

func NonWindowSQLTokens

func NonWindowSQLTokens(aliases ...string) []string

func PrepareNonWindowSQLTemplate

func PrepareNonWindowSQLTemplate(sql string, aliases ...string) (string, int)

PrepareNonWindowSQLTemplate converts authored property-style non-window SQL access into the typed View context method used by compiled SQL templates. Matching tokens in protected SQL text are wrapped in Velty's literal escape syntax so evaluation emits them unchanged.

func StripParentKeyCalls

func StripParentKeyCalls(sql string) (string, int, error)

func ValidateNonWindowSQLAliases

func ValidateNonWindowSQLAliases(sql string, aliases ...string) error

Types

type NonWindowSQLAccess

type NonWindowSQLAccess struct {
	Raw   string
	Alias string
	Start int
	End   int
}

func NonWindowSQLAccesses

func NonWindowSQLAccesses(sql string) []NonWindowSQLAccess

NonWindowSQLAccesses parses unqualified and named non-window SQL references at SQL code positions. Protected SQL text is skipped by the shared lexer.

type ParentKeyCall

type ParentKeyCall struct {
	Raw     string
	Method  string
	Prefix  string
	Columns []string
	Start   int
	End     int
}

func ParentKeyCalls

func ParentKeyCalls(sql string) ([]ParentKeyCall, error)

ParentKeyCalls parses the original Datly $View parent-key helper family in source order. It uses balanced-group parsing and an explicit method grammar.

type ParentKeyExpander

type ParentKeyExpander struct {
	Dialect       *info.Dialect
	ScalarValues  []any
	CompositeRows [][]interface{}
	Exclude       bool
}

ParentKeyExpander owns one invocation's parent-key SQL rendering inputs. Both plain builder macros and compiled Velty $View methods delegate here.

func (ParentKeyExpander) Expand

func (e ParentKeyExpander) Expand(call ParentKeyCall) (string, []any, error)

Jump to

Keyboard shortcuts

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