Documentation
¶
Overview ¶
Package jointree supports the query buildNodeTree process.
Index ¶
- type Element
- func (j *Element) CalculationsIter() iter.Seq2[string, query.Node]
- func (j *Element) ColumnIter() iter.Seq[*Element]
- func (j *Element) FindCalculation(alias string) query.Node
- func (j *Element) IsArray() bool
- func (j *Element) PrimaryKey() *Element
- func (j *Element) SelectedReferences() (refs []*Element)
- func (j *Element) SelectsIter() iter.Seq[*Element]
- func (j *Element) String() string
- type JoinTree
- func (t *JoinTree) CalculationsIter() iter.Seq2[string, query.Node]
- func (t *JoinTree) FindAlias(alias string) query.Node
- func (t *JoinTree) FindElement(node query.Node) *Element
- func (t *JoinTree) HasAggregates() bool
- func (t *JoinTree) HasCalcs() bool
- func (t *JoinTree) HasSelects() bool
- func (t *JoinTree) SelectsIter() iter.Seq[*Element]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element struct {
QueryNode query.Node
Parent *Element
References []*Element // TableNodeI objects
Columns []*Element // All columns that will be used to build the query, including those in Where, OrderBy and other clauses
SelectedColumns maps.SliceSet[*Element] // Pointers to elements in Columns that will be returned in the query. Using a SliceSet to iterate in the order given.
Alias string // computed or assigned alias
Calculations map[string]query.Node // calculations attached to this node by alias
IsPK bool
}
Element is used to build the join tree. The join tree creates a hierarchy of joined nodes that let us generate aliases, serialize the query, and afterward, unpack the results.
func (*Element) CalculationsIter ¶
CalculationsIter iterates on all the calculations in this element and its sub elements.
func (*Element) ColumnIter ¶
ColumnIter iterates on all the columns in this element and its sub elements.
func (*Element) PrimaryKey ¶
PrimaryKey will return the primary key join tree item attached to this item, or nil if none exists. If the element is not the kind of element that can have a primary key, it will panic.
func (*Element) SelectedReferences ¶
SelectedReferences returns just the references that have selected columns. This helps filter out references that are just used for where clauses and the like.
func (*Element) SelectsIter ¶
SelectsIter iterates on all the selects in this element and its sub elements.
type JoinTree ¶
type JoinTree struct {
Root *Element
SubPrefix string
IsDistinct bool
Command query.BuilderCommand
Limits query.LimitParams
Condition query.Node
GroupBys []query.Node
OrderBys []query.Sorter
Having query.Node
// contains filtered or unexported fields
}
JoinTree is used by various goradd-orm database drivers to convert a query.Builder object into a query understandable by the database. Developers do not normally need to call code here unless they are making a custom database driver.
It analyzes a query.QueryBuilder object, combines all the nodes into a single tree structure, adds extra nodes implied by the query, and assigns aliases to the columns that will be selected.
func NewJoinTree ¶
NewJoinTree analyzes b and turns it into a JoinTree.
func (*JoinTree) CalculationsIter ¶
func (*JoinTree) FindAlias ¶
FindAlias searches the join tree for the given manually assigned alias and returns the node corresponding to the alias.
func (*JoinTree) FindElement ¶
FindElement will return the element matching node, or nil if not found.