Documentation
¶
Overview ¶
Package macro parses and expands Datly SQL macros such as ParentJoinOn, ParentKey, and parent NonWindowSQL access.
Index ¶
- func ExpandNonWindowSQL(sql string, nonWindowSQL string, aliases ...string) (string, int)
- func ExpandParentKeyCalls(sql string, dialect *info.Dialect, scalarValues []any, ...) (string, []any, int, error)
- func NonWindowSQLTokens(aliases ...string) []string
- func PrepareNonWindowSQLTemplate(sql string, aliases ...string) (string, int)
- func StripParentKeyCalls(sql string) (string, int, error)
- func ValidateNonWindowSQLAliases(sql string, aliases ...string) error
- type NonWindowSQLAccess
- type ParentKeyCall
- type ParentKeyExpander
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpandNonWindowSQL ¶
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 NonWindowSQLTokens ¶
func PrepareNonWindowSQLTemplate ¶
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.
Types ¶
type NonWindowSQLAccess ¶
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)