tree

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: Apache-2.0 Imports: 3 Imported by: ? modules, 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

Index

Constants

This section is empty.

Variables

View Source
var JoinTypes = [...]string{
	"CROSS",
	"INNER",
	"LEFT",
	"RIGHT",
	"FULL",
	"IMPLICIT",
}

JoinTypes is join type strings

View Source
var LogicalBinaryExpTypes = [...]string{
	"AND",
	"OR",
	"NOOP",
}

LogicalBinaryExpTypes is logical binary exp type strings

View Source
var OrderTypes = [...]string{
	"ASC",
	"DESC",
}

OrderTypes is order type strings

Functions

This section is empty.

Types

type AliasedRelation

type AliasedRelation struct {
	IRelation
	Relation    IRelation
	Alias       *Identifier
	ColumnNames []*Identifier
}

AliasedRelation is alias relation

func NewAliasedRelation

func NewAliasedRelation(
	location *NodeLocation,
	relation IRelation,
	alias *Identifier,
	columns []*Identifier) *AliasedRelation

NewAliasedRelation creates NewAliasedRelation

func (*AliasedRelation) Accept

func (n *AliasedRelation) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type AllColumns

type AllColumns struct {
	// SelectItem is ISelectItem
	ISelectItem
	// Prefix is QualifiedName
	Prefix *QualifiedName
}

AllColumns are AllColumns

func NewAllColumns

func NewAllColumns(location *NodeLocation, prefix *QualifiedName) *AllColumns

NewAllColumns creates AllColumns

func (*AllColumns) Accept

func (n *AllColumns) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type AstVisitor

type AstVisitor interface {

	// VisitAliasedRelation visits the node
	VisitAliasedRelation(aliasedRelation *AliasedRelation, ctx interface{}) interface{}

	// VisitAllColumns visits the node
	VisitAllColumns(allColumns *AllColumns, ctx interface{}) interface{}

	// VisitExpression visits the node
	VisitExpression(exp IExpression, ctx interface{}) interface{}

	// VisitGroupBy visits the node
	VisitGroupBy(groupby *GroupBy, ctx interface{}) interface{}

	// VisitExpression visits the node
	VisitGroupingElement(groupElement IGroupingElement, ctx interface{}) interface{}

	// VisitIdentifier visits the node
	VisitIdentifier(identifier *Identifier, ctx interface{}) interface{}

	// VisitJoin visits the node
	VisitJoin(join *Join, ctx interface{}) interface{}

	// VisitLogicalBinaryExpression visits the node
	VisitLogicalBinaryExpression(logicalBinaryExpr *LogicalBinaryExpression, ctx interface{}) interface{}

	// VisitOrderBy visits the node
	VisitOrderBy(orderBy *OrderBy, ctx interface{}) interface{}

	// VisitQuery visits the node
	VisitQuery(query *Query, ctx interface{}) interface{}

	// VisitQueryBody visits the node
	VisitQueryBody(queryBody IQueryBody, ctx interface{}) interface{}

	// VisitQuerySpecification visits the node
	VisitQuerySpecification(querySpec *QuerySpecification, ctx interface{}) interface{}

	// VisitRelation visits the node
	VisitRelation(relation IRelation, ctx interface{}) interface{}

	// VisitSelect visits the node
	VisitSelect(sel *Select, ctx interface{}) interface{}

	// VisitSelectItem visits the node
	VisitSelectItem(selectItem ISelectItem, ctx interface{}) interface{}

	// VisitSimpleGroupBy visits the node
	VisitSimpleGroupBy(simpleGroupBy *SimpleGroupBy, ctx interface{}) interface{}

	// VisitSingleColumn visits the node
	VisitSingleColumn(singleColumn *SingleColumn, ctx interface{}) interface{}

	// VisitSortItem visits the node
	VisitSortItem(sortItem *SortItem, ctx interface{}) interface{}

	// VisitStatement visits the node
	VisitStatement(statement IStatement, ctx interface{}) interface{}

	// VisitTable visits the node
	VisitTable(table *Table, ctx interface{}) interface{}

	// VisitTableSubquery visits the node
	VisitTableSubquery(tableSubquery *TableSubquery, ctx interface{}) interface{}

	// VisitWith visits the node
	VisitWith(with *With, ctx interface{}) interface{}

	// VisitWithQuery visits the node
	VisitWithQuery(with *WithQuery, ctx interface{}) interface{}
	// contains filtered or unexported methods
}

AstVisitor is a visitor

type Expression

type Expression struct {
	// Node is an INode
	*Node
}

Expression is an IExpression

func NewExpression

func NewExpression(location *NodeLocation) *Expression

NewExpression creates Expression

func (*Expression) Accept

func (e *Expression) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type GroupBy

type GroupBy struct {
	// Node is INode
	INode
	IsDistinct       bool
	GroupingElements []IGroupingElement
}

GroupBy is GroupBy

func NewGroupBy

func NewGroupBy(location *NodeLocation, distinct bool, elements []IGroupingElement) *GroupBy

NewGroupBy creates GroupBy

func (*GroupBy) Accept

func (e *GroupBy) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type GroupingElement

type GroupingElement struct {
	// Node is INode
	INode
}

GroupingElement is IGroupingElement

func NewGroupingElement

func NewGroupingElement(location *NodeLocation) *GroupingElement

NewGroupingElement creates GroupingElement

func (*GroupingElement) Accept

func (g *GroupingElement) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type IExpression

type IExpression interface {
	// INode is interface
	INode
}

IExpression is interface

type IGroupingElement

type IGroupingElement interface {
	// INode is interface
	INode
}

IGroupingElement is interface

type IJoinCriteria

type IJoinCriteria interface {
	// GetNodes returns the list of nodes
	GetNodes() []INode
}

IJoinCriteria is interface

type INode

type INode interface {
	SetValue(value string)
	GetValue() string
	Accept(visitor AstVisitor, ctx interface{}) interface{}
}

INode is interface

type IQueryBody

type IQueryBody interface {
	// IRelation is interface
	IRelation
}

IQueryBody is interface

type IRelation

type IRelation interface {
	// INode is interface
	INode
}

IRelation is interface

type ISelectItem

type ISelectItem interface {
	// INode is interface
	INode
}

ISelectItem is interface

type IStatement

type IStatement interface {
	// INode is interface
	INode
}

IStatement is interface

type Identifier

type Identifier struct {
	// Expression is IExpression
	IExpression
	// Value is Identifier text
	Value string
	// Delimited is flag
	Delimited bool
}

Identifier is Identifier

func NewIdentifier

func NewIdentifier(location *NodeLocation, value string, delimited bool) *Identifier

NewIdentifier creates Identifier

func (*Identifier) Accept

func (e *Identifier) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type Join

type Join struct {
	// IRelation is interface
	IRelation
	// Type is join type
	Type JoinType
	// Left is IRelation
	Left IRelation
	// Right is IRelation
	Right IRelation
	// Criteria is on condition
	Criteria IJoinCriteria
}

Join is Join

func NewJoin

func NewJoin(location *NodeLocation, joinType JoinType, left, right IRelation, criteria IJoinCriteria) *Join

NewJoin creates Join

func (*Join) Accept

func (e *Join) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type JoinOn

type JoinOn struct {
	// IJoinCriteria is interface
	IJoinCriteria
	Expr IExpression
}

JoinOn is natural join

func NewJoinOn

func NewJoinOn(expr IExpression) *JoinOn

NewJoinOn creates JoinOn

func (*JoinOn) GetNodes

func (j *JoinOn) GetNodes() []INode

GetNodes returns empty

type JoinType

type JoinType int

JoinType is join type

const (
	// CROSS is CROSS
	CROSS JoinType = iota
	// INNER is INNER
	INNER
	// LEFT is LEFT
	LEFT
	// RIGHT is RIGHT
	RIGHT
	// FULL is FULL
	FULL
	// IMPLICIT is IMPLICIT
	IMPLICIT
)

type JoinUsing

type JoinUsing struct {
	// IJoinCriteria is interface
	IJoinCriteria
	Columns []*Identifier
}

JoinUsing is natural join

func NewJoinUsing

func NewJoinUsing(columns []*Identifier) *JoinUsing

NewJoinUsing creates JoinUsing

func (*JoinUsing) GetNodes

func (j *JoinUsing) GetNodes() []INode

GetNodes returns empty

type LogicalBinaryExpType

type LogicalBinaryExpType int

LogicalBinaryExpType is logical binary exp type

const (
	// AND is logic
	AND LogicalBinaryExpType = iota
	// OR is logic
	OR
	// NOOP is logic
	NOOP
)

type LogicalBinaryExpression

type LogicalBinaryExpression struct {
	IExpression
	LogicType LogicalBinaryExpType
	Left      IExpression
	Right     IExpression
}

LogicalBinaryExpression is IExpression

func NewLogicalBinaryExpression

func NewLogicalBinaryExpression(location *NodeLocation, logicType LogicalBinaryExpType,
	left, right IExpression) *LogicalBinaryExpression

NewLogicalBinaryExpression creates LogicalBinaryExpression

func (*LogicalBinaryExpression) Accept

func (e *LogicalBinaryExpression) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type NaturalJoin

type NaturalJoin struct {
	// IJoinCriteria is interface
	IJoinCriteria
}

NaturalJoin is natural join

func NewNaturalJoin

func NewNaturalJoin() *NaturalJoin

NewNaturalJoin creates NaturalJoin

func (*NaturalJoin) GetNodes

func (n *NaturalJoin) GetNodes() []INode

GetNodes returns empty

type Node

type Node struct {
	// Location is node location
	Location *NodeLocation
	// contains filtered or unexported fields
}

Node is INode

func NewNode

func NewNode(location *NodeLocation) *Node

NewNode creates Node

func (*Node) Accept

func (n *Node) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

func (*Node) GetValue

func (n *Node) GetValue() string

GetValue returns node token value

func (*Node) SetValue

func (n *Node) SetValue(value string)

SetValue sets node token value

type NodeLocation

type NodeLocation struct {
	// Line is #line
	Line int
	// CharPosition is #col
	CharPosition int
}

NodeLocation is position

type OrderBy

type OrderBy struct {
	// Node is INode
	INode
	// SortItems is list of SortItems
	SortItems []*SortItem
}

OrderBy is OrderBy

func NewOrderBy

func NewOrderBy(location *NodeLocation, sortItems []*SortItem) *OrderBy

NewOrderBy creates OrderBy

func (*OrderBy) Accept

func (n *OrderBy) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type OrderType

type OrderType int

OrderType is order type

const (
	// ASC is ASC
	ASC OrderType = iota
	// DESC is DESC
	DESC
)

type QualifiedName

type QualifiedName struct {
	// Parts is list of string
	Parts []string
	// OriginalParts is list of string
	OriginalParts []string
}

QualifiedName is column QualifiedName

func NewQualifiedName

func NewQualifiedName(originalParts, parts []string) *QualifiedName

NewQualifiedName creates QualifiedName

func (*QualifiedName) String

func (n *QualifiedName) String() string

String returns string

type Query

type Query struct {
	// Statement is IStatement
	IStatement
	// QueryBody is IQueryBody
	QueryBody IQueryBody
	// With is with
	With *With
	// OrderBy is orderby
	OrderBy *OrderBy
	// Limit is limit
	Limit string
}

Query is query

func NewQuery

func NewQuery(location *NodeLocation, with *With, queryBody IQueryBody, order *OrderBy, limit string) *Query

NewQuery creates Query

func (*Query) Accept

func (n *Query) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type QueryBody

type QueryBody struct {
	IRelation
}

QueryBody is QueryBody

func NewQueryBody

func NewQueryBody(location *NodeLocation) *QueryBody

NewQueryBody creates QueryBody

func (*QueryBody) Accept

func (q *QueryBody) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type QuerySpecification

type QuerySpecification struct {
	// QueryBody is IQueryBody
	IQueryBody
	// Select is Select
	Select *Select
	// From is IRelation
	From IRelation
	// Where is IExpression
	Where IExpression
	// GroupBy is GroupBy
	GroupBy *GroupBy
	// Having is IExpression
	Having IExpression
	// OrderBy is OrderBy
	OrderBy *OrderBy
	// Limit is limit
	Limit string
}

QuerySpecification is QuerySpecification

func NewQuerySpecification

func NewQuerySpecification(location *NodeLocation,
	sel *Select,
	from IRelation,
	where IExpression,
	groupBy *GroupBy,
	having IExpression,
	orderBy *OrderBy,
	limit string) *QuerySpecification

NewQuerySpecification creates QuerySpecification

func (*QuerySpecification) Accept

func (e *QuerySpecification) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type Relation

type Relation struct {
	INode
}

Relation is IRelation

func NewRelation

func NewRelation(location *NodeLocation) *Relation

NewRelation create Relation

func (*Relation) Accept

func (r *Relation) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type Select

type Select struct {
	// Node is INode
	INode
	// Distinct is distinct
	Distinct bool
	// SelectItems is list of ISelectItems
	SelectItems []ISelectItem
}

Select is select

func NewSelect

func NewSelect(location *NodeLocation, distinct bool, selectItems []ISelectItem) *Select

NewSelect creates Select

func (*Select) Accept

func (r *Select) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type SelectItem

type SelectItem struct {
	// Node is INode
	INode
}

SelectItem is SelectItem

func NewSelectItem

func NewSelectItem(location *NodeLocation) *SelectItem

NewSelectItem creates SelectItem

func (*SelectItem) Accept

func (r *SelectItem) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type SimpleGroupBy

type SimpleGroupBy struct {
	IGroupingElement
	// Columns is group by columns
	Columns []IExpression
}

SimpleGroupBy is group by

func NewSimpleGroupBy

func NewSimpleGroupBy(location *NodeLocation, expressions []IExpression) *SimpleGroupBy

NewSimpleGroupBy creates SimpleGroupBy

func (*SimpleGroupBy) Accept

func (q *SimpleGroupBy) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type SingleColumn

type SingleColumn struct {
	// SelectItem is interface
	ISelectItem
	// Alias is column alias
	Alias *Identifier
	// Expression is IExpression
	Expression IExpression
}

SingleColumn is select SingleColumn

func NewSingleColumn

func NewSingleColumn(location *NodeLocation, expr IExpression, alias *Identifier) *SingleColumn

NewSingleColumn creates SingleColumn

func (*SingleColumn) Accept

func (q *SingleColumn) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type SortItem

type SortItem struct {
	// Node is INode
	INode
	Expr  IExpression
	Order OrderType
}

SortItem is SortItem

func NewSortItem

func NewSortItem(location *NodeLocation, expr IExpression, order OrderType) *SortItem

NewSortItem creates SortItem

func (*SortItem) Accept

func (q *SortItem) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type Statement

type Statement struct {
	// Node is INode
	INode
}

Statement is Statement

func NewStatement

func NewStatement(location *NodeLocation) *Statement

NewStatement creates Statement

func (*Statement) Accept

func (q *Statement) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type Table

type Table struct {
	IQueryBody
	// Name is table name
	Name *QualifiedName
}

Table is table name

func NewTable

func NewTable(location *NodeLocation, name *QualifiedName) *Table

NewTable creates table name

func (*Table) Accept

func (q *Table) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type TableSubquery

type TableSubquery struct {
	IQueryBody
	// Query is subquery
	Query *Query
}

TableSubquery is subquery

func NewTableSubquery

func NewTableSubquery(location *NodeLocation, query *Query) *TableSubquery

NewTableSubquery creates TableSubquery

func (*TableSubquery) Accept

func (q *TableSubquery) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type With

type With struct {
	// Node is INode
	INode
	// Recursive is with Recursive
	Recursive bool
	// Queries is WithQuery
	Queries []*WithQuery
}

With is With

func NewWith

func NewWith(location *NodeLocation, recursive bool, queries []*WithQuery) *With

NewWith creates With

func (*With) Accept

func (n *With) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

type WithQuery

type WithQuery struct {
	// Node is INode
	INode
	// Name is name
	Name *Identifier
	// Query is query
	Query *Query
	// ColumnAliases is ColumnAliases
	ColumnAliases []*Identifier
}

WithQuery is WithQuery

func NewWithQuery

func NewWithQuery(location *NodeLocation, name *Identifier, query *Query, columnAliases []*Identifier) *WithQuery

NewWithQuery creates WithQuery

func (*WithQuery) Accept

func (q *WithQuery) Accept(visitor AstVisitor, ctx interface{}) interface{}

Accept accepts visitor

Jump to

Keyboard shortcuts

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