Documentation
¶
Index ¶
- Variables
- func As[T any](node SyntaxNode) (T, error)
- func AsOptionalIdentifier(identifier Identifier) models.Optional[Identifier]
- func IDSliceToInt8Array(value []graph.ID) (pgtype.Int8Array, error)
- func Int32SliceToInt4Array(value []int32) (pgtype.Int4Array, error)
- func IsAggregateFunction(function Identifier) bool
- func IsReservedIdentifier(identifier Identifier) bool
- func JSONBToProperties(jsonb pgtype.JSONB) (*graph.Properties, error)
- func MapStringAnyToJSONB(values map[string]any) (pgtype.JSONB, error)
- func MatcherAsJSONB(fieldName string, value any) (pgtype.JSONB, error)
- func MustMatcherAsJSONB(fieldName string, value any) pgtype.JSONB
- func NegotiateValue(value any) (any, error)
- func OperatorIsBoolean(operator Expression) bool
- func OperatorIsComparator(operator Expression) bool
- func OperatorIsIn(operator Expression, matchers ...Expression) bool
- func OperatorIsPropertyLookup(operator Expression) bool
- func PropertiesToJSONB(properties *graph.Properties) (pgtype.JSONB, error)
- func StringSliceToTextArray(values []string) (pgtype.TextArray, error)
- func ValueToJSONB(value any) (pgtype.JSONB, error)
- type AliasedExpression
- type AllExpression
- type AnyExpression
- type ArrayExpression
- type ArrayIndex
- type ArrayLiteral
- type Assignment
- type Between
- type BinaryExpression
- type Case
- type CommonTableExpression
- type CompositeValue
- type CompoundIdentifier
- func (s CompoundIdentifier) AsExpression() Expression
- func (s CompoundIdentifier) AsSelectItem() SelectItem
- func (s CompoundIdentifier) Copy() CompoundIdentifier
- func (s CompoundIdentifier) Field() Identifier
- func (s CompoundIdentifier) HasField() bool
- func (s CompoundIdentifier) IsBlank() bool
- func (s CompoundIdentifier) NodeType() string
- func (s CompoundIdentifier) Root() Identifier
- func (s CompoundIdentifier) String() string
- func (s CompoundIdentifier) Strings() []string
- type ConflictAction
- type ConflictTarget
- type DataType
- func (s DataType) ArrayBaseType() DataType
- func (s DataType) CoerceToSupertype(other DataType) (DataType, bool)
- func (s DataType) IsArrayType() bool
- func (s DataType) IsComparable(other DataType, operator Operator) bool
- func (s DataType) IsKnown() bool
- func (s DataType) MatchesOneOf(others ...DataType) bool
- func (s DataType) NodeType() string
- func (s DataType) OperatorResultType(other DataType, operator Operator) (DataType, bool)
- func (s DataType) String() string
- func (s DataType) ToArrayType() (DataType, error)
- type Delete
- type DoNothing
- type DoUpdate
- type ExistsExpression
- type Expression
- type FormattingLiteral
- type FromClause
- type FunctionCall
- type Future
- type Identifier
- type IdentifierSet
- func (s *IdentifierSet) Add(identifiers ...Identifier) *IdentifierSet
- func (s *IdentifierSet) CheckedAdd(identifier Identifier) bool
- func (s *IdentifierSet) Clear()
- func (s *IdentifierSet) CombinedKey() Identifier
- func (s *IdentifierSet) Contains(other Identifier) bool
- func (s *IdentifierSet) Copy() *IdentifierSet
- func (s *IdentifierSet) IsEmpty() bool
- func (s *IdentifierSet) Len() int
- func (s *IdentifierSet) Matches(other *IdentifierSet) bool
- func (s *IdentifierSet) MergeSet(other *IdentifierSet) *IdentifierSet
- func (s *IdentifierSet) Remove(others ...Identifier) *IdentifierSet
- func (s *IdentifierSet) RemoveSet(other *IdentifierSet) *IdentifierSet
- func (s *IdentifierSet) Satisfies(other *IdentifierSet) bool
- func (s *IdentifierSet) Slice() []Identifier
- func (s *IdentifierSet) Strings() []string
- type InExpression
- type InSubquery
- type Insert
- type Join
- type JoinOperator
- type JoinType
- type KindListLiteral
- type KindMapper
- type Literal
- type LiteralNodeValue
- type MatchedDelete
- type MatchedUpdate
- type Materialized
- type Merge
- type MergeAction
- type OnConflict
- type Operator
- type OrderBy
- type Parameter
- type Parenthetical
- type Projection
- type ProjectionFrom
- type Query
- type RecordShape
- type RowColumnReference
- type Select
- type SelectItem
- type SetExpression
- type SetOperation
- type Statement
- type Subquery
- type SymbolTable
- func (s *SymbolTable) Add(symbol any)
- func (s *SymbolTable) AddCompoundIdentifier(identifier CompoundIdentifier)
- func (s *SymbolTable) AddIdentifier(identifier Identifier)
- func (s *SymbolTable) AddTable(symbols *SymbolTable)
- func (s *SymbolTable) Contains(symbol any) bool
- func (s *SymbolTable) EachCompoundIdentifier(each func(next CompoundIdentifier) bool)
- func (s *SymbolTable) EachIdentifier(each func(next Identifier) bool)
- func (s *SymbolTable) IsEmpty() bool
- func (s *SymbolTable) NotIn(exclusions *SymbolTable) *SymbolTable
- func (s *SymbolTable) RootIdentifiers() *IdentifierSet
- type SyntaxNode
- type SyntaxNodeFuture
- type TableAlias
- type TableReference
- type TypeCast
- type TypeHinted
- type UnaryExpression
- type UnmatchedAction
- type Update
- type Values
- type Variadic
- type Wildcard
- type Window
- type WindowFrame
- type WindowFrameBoundary
- type WindowFrameBoundaryType
- type WindowFrameUnit
- type With
- type WrappedNode
Constants ¶
This section is empty.
Variables ¶
var ( NodeTableColumns = []Identifier{ ColumnID, ColumnKindIDs, ColumnProperties, } EdgeTableColumns = []Identifier{ ColumnID, ColumnStartID, ColumnEndID, ColumnKindID, ColumnProperties, } )
var CompositeTypes = []DataType{NodeComposite, NodeCompositeArray, EdgeComposite, EdgeCompositeArray, PathComposite}
var (
ErrNoAvailableArrayDataType = errors.New("data type has no direct array representation")
)
Functions ¶
func As ¶
func As[T any](node SyntaxNode) (T, error)
As is a helper function that takes a SyntaxNode and attempts to cast it to the type represented by T. If the node passed is equal to nil then the empty value of T is returned. If the typed node does not convert to the type represented by T then an error is returned.
func AsOptionalIdentifier ¶
func AsOptionalIdentifier(identifier Identifier) models.Optional[Identifier]
func IsAggregateFunction ¶
func IsAggregateFunction(function Identifier) bool
func IsReservedIdentifier ¶
func IsReservedIdentifier(identifier Identifier) bool
func JSONBToProperties ¶
func JSONBToProperties(jsonb pgtype.JSONB) (*graph.Properties, error)
func NegotiateValue ¶
func OperatorIsBoolean ¶
func OperatorIsBoolean(operator Expression) bool
func OperatorIsComparator ¶
func OperatorIsComparator(operator Expression) bool
func OperatorIsIn ¶
func OperatorIsIn(operator Expression, matchers ...Expression) bool
func OperatorIsPropertyLookup ¶
func OperatorIsPropertyLookup(operator Expression) bool
func PropertiesToJSONB ¶
func PropertiesToJSONB(properties *graph.Properties) (pgtype.JSONB, error)
func StringSliceToTextArray ¶
Types ¶
type AliasedExpression ¶
type AliasedExpression struct {
Expression Expression
Alias models.Optional[Identifier]
}
func (AliasedExpression) AsExpression ¶
func (s AliasedExpression) AsExpression() Expression
func (AliasedExpression) AsSelectItem ¶
func (s AliasedExpression) AsSelectItem() SelectItem
func (AliasedExpression) NodeType ¶
func (s AliasedExpression) NodeType() string
type AllExpression ¶
type AllExpression struct {
Expression
}
func NewAllExpression ¶
func NewAllExpression(inner Expression) AllExpression
type AnyExpression ¶
type AnyExpression struct {
Expression
CastType DataType
}
func NewAnyExpression ¶
func NewAnyExpression(inner Expression, castType DataType) *AnyExpression
func NewAnyExpressionHinted ¶
func NewAnyExpressionHinted(inner TypeHinted) *AnyExpression
func (AnyExpression) AsExpression ¶
func (s AnyExpression) AsExpression() Expression
func (AnyExpression) NodeType ¶
func (s AnyExpression) NodeType() string
func (AnyExpression) TypeHint ¶
func (s AnyExpression) TypeHint() DataType
type ArrayExpression ¶
type ArrayExpression struct {
Expression Expression
}
func (ArrayExpression) AsExpression ¶
func (s ArrayExpression) AsExpression() Expression
func (ArrayExpression) NodeType ¶
func (s ArrayExpression) NodeType() string
type ArrayIndex ¶
type ArrayIndex struct {
Expression Expression
Indexes []Expression
}
func (ArrayIndex) AsExpression ¶
func (s ArrayIndex) AsExpression() Expression
func (ArrayIndex) NodeType ¶
func (s ArrayIndex) NodeType() string
type ArrayLiteral ¶
type ArrayLiteral struct {
Values []Expression
CastType DataType
}
func NewArrayLiteral ¶
func NewArrayLiteral[T any](values []T, castType DataType) (ArrayLiteral, error)
func (ArrayLiteral) AsExpression ¶
func (s ArrayLiteral) AsExpression() Expression
func (ArrayLiteral) AsSelectItem ¶
func (s ArrayLiteral) AsSelectItem() SelectItem
func (ArrayLiteral) NodeType ¶
func (s ArrayLiteral) NodeType() string
func (ArrayLiteral) TypeHint ¶
func (s ArrayLiteral) TypeHint() DataType
type Assignment ¶
type Assignment interface {
SyntaxNode
AsAssignment() Assignment
}
Assignment is an expression that can be used as an assignment.
type Between ¶
type Between struct {
Expression Expression
Low Expression
High Expression
Negated bool
}
Between represents a comparison expression between a low expression and high expression. <expr> [not] between <low> and <high>
type BinaryExpression ¶
type BinaryExpression struct {
Operator Operator
LOperand Expression
ROperand Expression
}
<expr> > <expr> table.column > 12345
func NewBinaryExpression ¶
func NewBinaryExpression(left Expression, operator Operator, right Expression) *BinaryExpression
func NewJSONTextFieldLookup ¶
func NewJSONTextFieldLookup(reference CompoundIdentifier, field Identifier) *BinaryExpression
func NewPropertyLookup ¶
func NewPropertyLookup(identifier CompoundIdentifier, reference Literal) *BinaryExpression
func (BinaryExpression) AsAssignment ¶
func (s BinaryExpression) AsAssignment() Assignment
func (BinaryExpression) AsExpression ¶
func (s BinaryExpression) AsExpression() Expression
func (BinaryExpression) AsSelectItem ¶
func (s BinaryExpression) AsSelectItem() SelectItem
func (BinaryExpression) NodeType ¶
func (s BinaryExpression) NodeType() string
type Case ¶
type Case struct {
Operand Expression
Conditions []Expression
Then []Expression
Else Expression
}
Case represents a pattern matching syntax node:
CASE
WHEN condition1 THEN result1 WHEN condition2 THEN result2 WHEN conditionN THEN resultN ELSE result
END;
type CommonTableExpression ¶
type CommonTableExpression struct {
Alias TableAlias
Materialized *Materialized
Query Query
}
CommonTableExpression is a named component of a `WITH` query and provides a way to write auxiliary statements for use in a larger query
func (CommonTableExpression) NodeType ¶
func (s CommonTableExpression) NodeType() string
type CompositeValue ¶
type CompositeValue struct {
Values []Expression
DataType DataType
}
func (CompositeValue) AsExpression ¶
func (s CompositeValue) AsExpression() Expression
func (CompositeValue) AsSelectItem ¶
func (s CompositeValue) AsSelectItem() SelectItem
func (CompositeValue) NodeType ¶
func (s CompositeValue) NodeType() string
type CompoundIdentifier ¶
type CompoundIdentifier []Identifier
func AsCompoundIdentifier ¶
func AsCompoundIdentifier[T string | Identifier](parts ...T) CompoundIdentifier
func (CompoundIdentifier) AsExpression ¶
func (s CompoundIdentifier) AsExpression() Expression
func (CompoundIdentifier) AsSelectItem ¶
func (s CompoundIdentifier) AsSelectItem() SelectItem
func (CompoundIdentifier) Copy ¶
func (s CompoundIdentifier) Copy() CompoundIdentifier
func (CompoundIdentifier) Field ¶
func (s CompoundIdentifier) Field() Identifier
func (CompoundIdentifier) HasField ¶
func (s CompoundIdentifier) HasField() bool
func (CompoundIdentifier) IsBlank ¶
func (s CompoundIdentifier) IsBlank() bool
func (CompoundIdentifier) NodeType ¶
func (s CompoundIdentifier) NodeType() string
func (CompoundIdentifier) Root ¶
func (s CompoundIdentifier) Root() Identifier
func (CompoundIdentifier) String ¶
func (s CompoundIdentifier) String() string
func (CompoundIdentifier) Strings ¶
func (s CompoundIdentifier) Strings() []string
type ConflictAction ¶
type ConflictAction interface {
Expression
AsConflictAction() ConflictAction
}
ConflictAction is an expression that is evaluated as part of an OnConflict expression.
type ConflictTarget ¶
type ConflictTarget struct {
Columns []Expression
Constraint CompoundIdentifier
}
func (ConflictTarget) AsExpression ¶
func (s ConflictTarget) AsExpression() Expression
func (ConflictTarget) NodeType ¶
func (s ConflictTarget) NodeType() string
type DataType ¶
type DataType string
const ( // UnsetDataType represents a DataType that has not been visited by any logic. It is the default, zero-value for // the DataType type. UnsetDataType DataType = "" // UnknownDataType represents a DataType that has been visited by type inference logic but remains unknowable. UnknownDataType DataType = "unknown" Null DataType = "null" Any DataType = "any" NodeComposite DataType = "nodecomposite" EdgeComposite DataType = "edgecomposite" PathComposite DataType = "pathcomposite" Int DataType = "int" Int2 DataType = "int2" Int4 DataType = "int4" Int8 DataType = "int8" Float4 DataType = "float4" Float8 DataType = "float8" Boolean DataType = "bool" Text DataType = "text" JSONB DataType = "jsonb" Numeric DataType = "numeric" AnyArray DataType = "anyarray" NodeCompositeArray DataType = "nodecomposite[]" EdgeCompositeArray DataType = "edgecomposite[]" IntArray DataType = "int[]" Int2Array DataType = "int2[]" Int4Array DataType = "int4[]" Int8Array DataType = "int8[]" Float4Array DataType = "float4[]" Float8Array DataType = "float8[]" TextArray DataType = "text[]" JSONBArray DataType = "jsonb[]" NumericArray DataType = "numeric[]" Date DataType = "date" TimeWithTimeZone DataType = "time with time zone" TimeWithoutTimeZone DataType = "time without time zone" Interval DataType = "interval" TimestampWithTimeZone DataType = "timestamp with time zone" TimestampWithoutTimeZone DataType = "timestamp without time zone" Scope DataType = "scope" ParameterIdentifier DataType = "parameter_identifier" ExpansionPattern DataType = "expansion_pattern" ExpansionPath DataType = "expansion_path" ExpansionRootNode DataType = "expansion_root_node" ExpansionEdge DataType = "expansion_edge" ExpansionTerminalNode DataType = "expansion_terminal_node" )
func ValueToDataType ¶
func (DataType) ArrayBaseType ¶
func (DataType) CoerceToSupertype ¶
CoerceToSupertype attempts to take the super of the type s and the type other
func (DataType) IsArrayType ¶
func (DataType) IsComparable ¶
func (DataType) MatchesOneOf ¶
func (DataType) OperatorResultType ¶
func (DataType) ToArrayType ¶
type Delete ¶
type Delete struct {
From []TableReference
Using []FromClause
Where Expression
Returning []SelectItem
}
Delete is a SQL statement that is evaluated to remove data from a target table.
func (Delete) AsExpression ¶
func (s Delete) AsExpression() Expression
func (Delete) AsSetExpression ¶
func (s Delete) AsSetExpression() SetExpression
func (Delete) AsStatement ¶
type DoUpdate ¶
type DoUpdate struct {
Assignments []Assignment
Where Expression
}
func (DoUpdate) AsConflictAction ¶
func (s DoUpdate) AsConflictAction() ConflictAction
func (DoUpdate) AsExpression ¶
func (s DoUpdate) AsExpression() Expression
type ExistsExpression ¶
ExistsExpression is an expression that is wrapped by an exists unary expression that can be optionally negated.
[not] exists(<query>)
func (ExistsExpression) AsExpression ¶
func (s ExistsExpression) AsExpression() Expression
func (ExistsExpression) AsSelectItem ¶
func (s ExistsExpression) AsSelectItem() SelectItem
func (ExistsExpression) NodeType ¶
func (s ExistsExpression) NodeType() string
type Expression ¶
type Expression interface {
SyntaxNode
AsExpression() Expression
}
Expression one or more syntax nodes that evaluate to a value.
func OptionalAnd ¶
func OptionalAnd(leftOperand Expression, rightOperand Expression) Expression
func OptionalBinaryExpressionJoin ¶
func OptionalBinaryExpressionJoin(optional Expression, operator Operator, conjoined Expression) Expression
type FormattingLiteral ¶
type FormattingLiteral string
FormattingLiteral is a syntax node that is used as a transparent formatting syntax node. The formatter will take the string value and emit it as-is.
func (FormattingLiteral) AsExpression ¶
func (s FormattingLiteral) AsExpression() Expression
func (FormattingLiteral) NodeType ¶
func (s FormattingLiteral) NodeType() string
func (FormattingLiteral) String ¶
func (s FormattingLiteral) String() string
type FromClause ¶
type FromClause struct {
Source Expression
Joins []Join
}
func (FromClause) NodeType ¶
func (s FromClause) NodeType() string
type FunctionCall ¶
type FunctionCall struct {
Bare bool
Distinct bool
Function Identifier
Parameters []Expression
Over *Window
CastType DataType
}
func (FunctionCall) AsAssignment ¶
func (s FunctionCall) AsAssignment() Assignment
func (FunctionCall) AsExpression ¶
func (s FunctionCall) AsExpression() Expression
func (FunctionCall) AsSelectItem ¶
func (s FunctionCall) AsSelectItem() SelectItem
func (FunctionCall) NodeType ¶
func (s FunctionCall) NodeType() string
func (FunctionCall) TypeHint ¶
func (s FunctionCall) TypeHint() DataType
type Future ¶
type Future[U any] struct { SyntaxNode SyntaxNode Data U DataType DataType }
func (Future[U]) AsExpression ¶
func (s Future[U]) AsExpression() Expression
func (Future[U]) Unwrap ¶
func (s Future[U]) Unwrap() SyntaxNode
type Identifier ¶
type Identifier string
const ( FunctionUnidirectionalASPHarness Identifier = "unidirectional_asp_harness" FunctionUnidirectionalSPHarness Identifier = "unidirectional_sp_harness" FunctionBidirectionalASPHarness Identifier = "bidirectional_asp_harness" FunctionIntArrayUnique Identifier = "uniq" FunctionIntArraySort Identifier = "sort" FunctionJSONBToTextArray Identifier = "jsonb_to_text_array" FunctionJSONBArrayElementsText Identifier = "jsonb_array_elements_text" FunctionJSONBBuildObject Identifier = "jsonb_build_object" FunctionJSONBArrayLength Identifier = "jsonb_array_length" FunctionArrayLength Identifier = "array_length" FunctionArrayAggregate Identifier = "array_agg" FunctionArrayRemove Identifier = "array_remove" FunctionMin Identifier = "min" FunctionMax Identifier = "max" FunctionSum Identifier = "sum" FunctionAvg Identifier = "avg" FunctionLocalTimestamp Identifier = "localtimestamp" FunctionLocalTime Identifier = "localtime" FunctionCurrentTime Identifier = "current_time" FunctionCurrentDate Identifier = "current_date" FunctionNow Identifier = "now" FunctionToLower Identifier = "lower" FunctionToUpper Identifier = "upper" FunctionCoalesce Identifier = "coalesce" FunctionUnnest Identifier = "unnest" FunctionJSONBSet Identifier = "jsonb_set" FunctionCount Identifier = "count" FunctionStringToArray Identifier = "string_to_array" FunctionEdgesToPath Identifier = "edges_to_path" FunctionNodesToPath Identifier = "nodes_to_path" FunctionExtract Identifier = "extract" )
const ( WildcardIdentifier Identifier = "*" EpochIdentifier Identifier = "epoch" )
const ( StringLiteralNull = "null" StringLiteralEmptyArray = "[]" TableNode Identifier = "node" TableEdge Identifier = "edge" ColumnID Identifier = "id" ColumnPath Identifier = "path" ColumnProperties Identifier = "properties" ColumnKindIDs Identifier = "kind_ids" ColumnKindID Identifier = "kind_id" ColumnGraphID Identifier = "graph_id" ColumnStartID Identifier = "start_id" ColumnEndID Identifier = "end_id" )
func AsIdentifiers ¶
func AsIdentifiers(strs ...string) []Identifier
func (Identifier) AsCompoundIdentifier ¶
func (s Identifier) AsCompoundIdentifier() CompoundIdentifier
func (Identifier) AsExpression ¶
func (s Identifier) AsExpression() Expression
func (Identifier) AsSelectItem ¶
func (s Identifier) AsSelectItem() SelectItem
func (Identifier) Matches ¶
func (s Identifier) Matches(others ...Identifier) bool
func (Identifier) NodeType ¶
func (s Identifier) NodeType() string
func (Identifier) String ¶
func (s Identifier) String() string
type IdentifierSet ¶
type IdentifierSet struct {
// contains filtered or unexported fields
}
IdentifierSet represents a set of identifiers backed by a map[Identifier]struct{} instance.
func AllocateIdentifierSet ¶
func AllocateIdentifierSet(length int) *IdentifierSet
func AsIdentifierSet ¶
func AsIdentifierSet(identifiers ...Identifier) *IdentifierSet
func NewIdentifierSet ¶
func NewIdentifierSet() *IdentifierSet
func (*IdentifierSet) Add ¶
func (s *IdentifierSet) Add(identifiers ...Identifier) *IdentifierSet
func (*IdentifierSet) CheckedAdd ¶
func (s *IdentifierSet) CheckedAdd(identifier Identifier) bool
func (*IdentifierSet) Clear ¶
func (s *IdentifierSet) Clear()
func (*IdentifierSet) CombinedKey ¶
func (s *IdentifierSet) CombinedKey() Identifier
func (*IdentifierSet) Contains ¶
func (s *IdentifierSet) Contains(other Identifier) bool
func (*IdentifierSet) Copy ¶
func (s *IdentifierSet) Copy() *IdentifierSet
func (*IdentifierSet) IsEmpty ¶
func (s *IdentifierSet) IsEmpty() bool
func (*IdentifierSet) Len ¶
func (s *IdentifierSet) Len() int
func (*IdentifierSet) Matches ¶
func (s *IdentifierSet) Matches(other *IdentifierSet) bool
func (*IdentifierSet) MergeSet ¶
func (s *IdentifierSet) MergeSet(other *IdentifierSet) *IdentifierSet
func (*IdentifierSet) Remove ¶
func (s *IdentifierSet) Remove(others ...Identifier) *IdentifierSet
func (*IdentifierSet) RemoveSet ¶
func (s *IdentifierSet) RemoveSet(other *IdentifierSet) *IdentifierSet
func (*IdentifierSet) Satisfies ¶
func (s *IdentifierSet) Satisfies(other *IdentifierSet) bool
Satisfies returns true if the `other`is a subset of `s`
func (*IdentifierSet) Slice ¶
func (s *IdentifierSet) Slice() []Identifier
func (*IdentifierSet) Strings ¶
func (s *IdentifierSet) Strings() []string
type InExpression ¶
type InExpression struct {
Expression Expression
List []Expression
Negated bool
}
InExpression represents a contains operation against a list of evaluated expressions: m.identifier in (val1, val2, ...)
type InSubquery ¶
type InSubquery struct {
Expression Expression
Query Query
Negated bool
}
InSubquery represents a contains expression against a suq-query. [not] in (<Select> ...)
type Insert ¶
type Insert struct {
Table TableReference
Shape *RecordShape
OnConflict *OnConflict
Source *Query
Returning []SelectItem
}
Insert is a SQL statement that is evaluated to insert data into a target table.
func (Insert) AsStatement ¶
type Join ¶
type Join struct {
Table TableReference
JoinOperator JoinOperator
}
type JoinOperator ¶
type JoinOperator struct {
JoinType JoinType
Constraint Expression
}
func (JoinOperator) NodeType ¶
func (s JoinOperator) NodeType() string
type KindListLiteral ¶
func (KindListLiteral) AsExpression ¶
func (s KindListLiteral) AsExpression() Expression
func (KindListLiteral) NodeType ¶
func (s KindListLiteral) NodeType() string
type KindMapper ¶
type KindMapper interface {
MapKinds(ctx context.Context, kinds graph.Kinds) ([]int16, error)
AssertKinds(ctx context.Context, kinds graph.Kinds) ([]int16, error)
}
KindMapper is an interface that represents a service that can map a given slice of graph.Kind to a slice of int16 numeric identifiers.
type Literal ¶
Literal is a type-hinted literal SQL value.
func NewLiteral ¶
func NullLiteral ¶
func NullLiteral() Literal
func (Literal) AsExpression ¶
func (s Literal) AsExpression() Expression
func (Literal) AsSelectItem ¶
func (s Literal) AsSelectItem() SelectItem
type LiteralNodeValue ¶
type MatchedDelete ¶
type MatchedDelete struct {
Predicate Expression
}
func (MatchedDelete) AsExpression ¶
func (s MatchedDelete) AsExpression() Expression
func (MatchedDelete) AsMergeAction ¶
func (s MatchedDelete) AsMergeAction() MergeAction
func (MatchedDelete) NodeType ¶
func (s MatchedDelete) NodeType() string
type MatchedUpdate ¶
type MatchedUpdate struct {
Predicate Expression
Assignments []Assignment
}
func (MatchedUpdate) AsExpression ¶
func (s MatchedUpdate) AsExpression() Expression
func (MatchedUpdate) AsMergeAction ¶
func (s MatchedUpdate) AsMergeAction() MergeAction
func (MatchedUpdate) NodeType ¶
func (s MatchedUpdate) NodeType() string
type Materialized ¶
type Materialized struct {
Materialized bool
}
Materialized is an expression that represents a query hint for common table expressions that informs the query planner if it should prefer to materialize the given CTE.
func (Materialized) AsExpression ¶
func (s Materialized) AsExpression() Expression
func (Materialized) AsSetExpression ¶
func (s Materialized) AsSetExpression() SetExpression
func (Materialized) NodeType ¶
func (s Materialized) NodeType() string
type Merge ¶
type Merge struct {
Into bool
Table TableReference
Source TableReference
JoinTarget Expression
Actions []MergeAction
}
func (Merge) AsStatement ¶
type MergeAction ¶
type MergeAction interface {
Expression
AsMergeAction() MergeAction
}
MergeAction is an expression that can be used as the action of a merge statement.
type OnConflict ¶
type OnConflict struct {
Target *ConflictTarget
Action ConflictAction
}
OnConflict is an expression that outlines the target columns of a conflict and the action to be taken when a conflict is encountered.
func (OnConflict) AsExpression ¶
func (s OnConflict) AsExpression() Expression
func (OnConflict) NodeType ¶
func (s OnConflict) NodeType() string
type Operator ¶
type Operator string
const ( UnsetOperator Operator = "" OperatorUnion Operator = "union" OperatorConcatenate Operator = "||" OperatorArrayOverlap Operator = "&&" OperatorEquals Operator = "=" OperatorNotEquals Operator = "!=" OperatorGreaterThan Operator = ">" OperatorGreaterThanOrEqualTo Operator = ">=" OperatorLessThan Operator = "<" OperatorLessThanOrEqualTo Operator = "<=" OperatorLike Operator = "like" OperatorILike Operator = "ilike" OperatorPGArrayOverlap Operator = "operator (pg_catalog.&&)" OperatorAnd Operator = "and" OperatorOr Operator = "or" OperatorNot Operator = "not" OperatorJSONBFieldExists Operator = "?" OperatorJSONField Operator = "->" OperatorJSONTextField Operator = "->>" OperatorAdd Operator = "+" OperatorSubtract Operator = "-" OperatorMultiply Operator = "*" OperatorDivide Operator = "/" OperatorIn Operator = "in" OperatorIs Operator = "is" OperatorIsNot Operator = "is not" OperatorSimilarTo Operator = "similar to" OperatorRegexMatch Operator = "~" OperatorAssignment Operator = "=" OperatorAdditionAssignment Operator = "+=" OperatorCypherRegexMatch Operator = "=~" OperatorCypherStartsWith Operator = "starts with" OperatorCypherContains Operator = "contains" OperatorCypherEndsWith Operator = "ends with" OperatorCypherNotEquals Operator = "<>" OperatorPropertyLookup Operator = "property_lookup" OperatorKindAssignment Operator = "kind_assignment" )
func (Operator) AsExpression ¶
func (s Operator) AsExpression() Expression
type OrderBy ¶
type OrderBy struct {
Expression Expression
Ascending bool
}
func NewOrderBy ¶
func (OrderBy) AsExpression ¶
func (s OrderBy) AsExpression() Expression
type Parameter ¶
type Parameter struct {
Identifier Identifier
CastType DataType
}
func AsParameter ¶
func AsParameter(identifier Identifier, value any) (*Parameter, error)
func (Parameter) AsExpression ¶
func (s Parameter) AsExpression() Expression
func (Parameter) AsSelectItem ¶
func (s Parameter) AsSelectItem() SelectItem
type Parenthetical ¶
type Parenthetical struct {
Expression Expression
}
(<expr>)
func NewParenthetical ¶
func NewParenthetical(expr Expression) *Parenthetical
func (*Parenthetical) AsExpression ¶
func (s *Parenthetical) AsExpression() Expression
func (*Parenthetical) AsSelectItem ¶
func (s *Parenthetical) AsSelectItem() SelectItem
func (*Parenthetical) NodeType ¶
func (s *Parenthetical) NodeType() string
type Projection ¶
type Projection []SelectItem
Projection is an alias for a slice of SelectItem instances.
func (Projection) AsExpression ¶
func (s Projection) AsExpression() Expression
func (Projection) AsSyntaxNodes ¶
func (s Projection) AsSyntaxNodes() []SyntaxNode
func (Projection) NodeType ¶
func (s Projection) NodeType() string
type ProjectionFrom ¶
type ProjectionFrom struct {
Projection Projection
From []FromClause
}
func (ProjectionFrom) AsExpression ¶
func (s ProjectionFrom) AsExpression() Expression
func (ProjectionFrom) NodeType ¶
func (s ProjectionFrom) NodeType() string
type Query ¶
type Query struct {
CommonTableExpressions *With
Body SetExpression
OrderBy []*OrderBy
Offset Expression
Limit Expression
}
[with <CTE>] select * from table;
func (Query) AddCTE ¶
func (s Query) AddCTE(cte CommonTableExpression)
func (Query) AsExpression ¶
func (s Query) AsExpression() Expression
func (Query) AsSetExpression ¶
func (s Query) AsSetExpression() SetExpression
func (Query) AsStatement ¶
type RecordShape ¶
type RecordShape struct {
Columns []Identifier
}
RecordShape defines a list of column identifiers that name a record's fields: (id, enrolled)
func NewRecordShape ¶ added in v0.2.1
func NewRecordShape(columns []Identifier) *RecordShape
func (RecordShape) NodeType ¶
func (s RecordShape) NodeType() string
type RowColumnReference ¶
type RowColumnReference struct {
Identifier Expression
Column Identifier
}
func (RowColumnReference) AsExpression ¶
func (s RowColumnReference) AsExpression() Expression
func (RowColumnReference) AsSelectItem ¶
func (s RowColumnReference) AsSelectItem() SelectItem
func (RowColumnReference) NodeType ¶
func (s RowColumnReference) NodeType() string
type Select ¶
type Select struct {
Distinct bool
Projection Projection
From []FromClause
Where Expression
GroupBy []Expression
Having Expression
}
Select is a SQL expression that is evaluated to fetch data.
func (Select) AsExpression ¶
func (s Select) AsExpression() Expression
func (Select) AsSetExpression ¶
func (s Select) AsSetExpression() SetExpression
type SelectItem ¶
type SelectItem interface {
Expression
AsSelectItem() SelectItem
}
SelectItem is an expression that can be used as a projection.
type SetExpression ¶
type SetExpression interface {
Expression
AsSetExpression() SetExpression
}
SetExpression is an expression that represents a query body expression.
type SetOperation ¶
type SetOperation struct {
Operator Operator
LOperand SetExpression
ROperand SetExpression
All bool
Distinct bool
}
SetOperation is a binary expression that represents an operation to be applied to two set expressions:
select 1 union select 2;
func (SetOperation) AsExpression ¶
func (s SetOperation) AsExpression() Expression
func (SetOperation) AsSetExpression ¶
func (s SetOperation) AsSetExpression() SetExpression
func (SetOperation) NodeType ¶
func (s SetOperation) NodeType() string
type Statement ¶
type Statement interface {
SyntaxNode
AsStatement() Statement
}
Statement is a syntax node that does not evaluate to a value.
type Subquery ¶
type Subquery struct {
Query Query
}
func (Subquery) AsExpression ¶
func (s Subquery) AsExpression() Expression
type SymbolTable ¶
type SymbolTable struct {
// contains filtered or unexported fields
}
SymbolTable is a symbol table that has some generic functions for negotiating unique symbols from identifiers, compound identifiers, and other PgSQL AST elements.
func NewSymbolTable ¶
func NewSymbolTable() *SymbolTable
func (*SymbolTable) Add ¶
func (s *SymbolTable) Add(symbol any)
func (*SymbolTable) AddCompoundIdentifier ¶
func (s *SymbolTable) AddCompoundIdentifier(identifier CompoundIdentifier)
func (*SymbolTable) AddIdentifier ¶
func (s *SymbolTable) AddIdentifier(identifier Identifier)
func (*SymbolTable) AddTable ¶
func (s *SymbolTable) AddTable(symbols *SymbolTable)
func (*SymbolTable) Contains ¶
func (s *SymbolTable) Contains(symbol any) bool
func (*SymbolTable) EachCompoundIdentifier ¶
func (s *SymbolTable) EachCompoundIdentifier(each func(next CompoundIdentifier) bool)
func (*SymbolTable) EachIdentifier ¶
func (s *SymbolTable) EachIdentifier(each func(next Identifier) bool)
func (*SymbolTable) IsEmpty ¶
func (s *SymbolTable) IsEmpty() bool
func (*SymbolTable) NotIn ¶
func (s *SymbolTable) NotIn(exclusions *SymbolTable) *SymbolTable
func (*SymbolTable) RootIdentifiers ¶
func (s *SymbolTable) RootIdentifiers() *IdentifierSet
type SyntaxNode ¶
type SyntaxNode interface {
NodeType() string
}
SyntaxNode is the top-level interface for any of the modeled PgSQL AST syntax elements.
type SyntaxNodeFuture ¶
type SyntaxNodeFuture interface {
SyntaxNode
Unwrap() SyntaxNode
Satisfied() bool
}
SyntaxNodeFuture is a SyntaxNode that can be satisfied out-of-tree and communicate if it has been satisfied to upstream consumers. This is useful when a SyntaxNode is required to be embedded in a built syntax tree but can not be formally built itself due to ordering or missing dependency information (in the case of an existential subquery).
type TableAlias ¶
type TableAlias struct {
Name Identifier
Shape *RecordShape
}
TableAlias is an alias for a table with an optional record shape.
func (TableAlias) NodeType ¶
func (s TableAlias) NodeType() string
type TableReference ¶
type TableReference struct {
Name CompoundIdentifier
Binding models.Optional[Identifier]
}
func (TableReference) AsExpression ¶
func (s TableReference) AsExpression() Expression
func (TableReference) NodeType ¶
func (s TableReference) NodeType() string
type TypeCast ¶
type TypeCast struct {
Expression Expression
CastType DataType
}
TypeCast wraps a given expression in a type cast that matches the given DataType.
func (TypeCast) AsExpression ¶
func (s TypeCast) AsExpression() Expression
type TypeHinted ¶
type TypeHinted interface {
Expression
TypeHint() DataType
}
TypeHinted is an expression that contains a DataType hint that can be accessed by handlers.
func NewTypeCast ¶
func NewTypeCast(expression Expression, dataType DataType) TypeHinted
type UnaryExpression ¶
type UnaryExpression struct {
Operator Expression
Operand Expression
}
not <expr>
func NewUnaryExpression ¶
func NewUnaryExpression(operator Operator, operand Expression) *UnaryExpression
func (UnaryExpression) AsExpression ¶
func (s UnaryExpression) AsExpression() Expression
func (UnaryExpression) NodeType ¶
func (s UnaryExpression) NodeType() string
type UnmatchedAction ¶
type UnmatchedAction struct {
Predicate Expression
Columns []Identifier
Values Values
}
func (UnmatchedAction) AsExpression ¶
func (s UnmatchedAction) AsExpression() Expression
func (UnmatchedAction) AsMergeAction ¶
func (s UnmatchedAction) AsMergeAction() MergeAction
func (UnmatchedAction) NodeType ¶
func (s UnmatchedAction) NodeType() string
type Update ¶
type Update struct {
Table TableReference
Assignments []Assignment
From []FromClause
Where Expression
Returning []SelectItem
}
Update is a SQL statement that is evaluated to update data in a target table.
func (Update) AsExpression ¶
func (s Update) AsExpression() Expression
func (Update) AsSetExpression ¶
func (s Update) AsSetExpression() SetExpression
func (Update) AsStatement ¶
type Values ¶
type Values struct {
Values []Expression
}
Values represents a list of expressions to be taken as a value array: insert into table (id, enrolled) values (1, true);
func (Values) AsExpression ¶
func (s Values) AsExpression() Expression
func (Values) AsSetExpression ¶
func (s Values) AsSetExpression() SetExpression
type Variadic ¶
type Variadic struct {
Expression Expression
}
Variadic isrepresents a variadic expansion of the given expression.
func (Variadic) AsExpression ¶
func (s Variadic) AsExpression() Expression
type Wildcard ¶
type Wildcard struct{}
func (Wildcard) AsExpression ¶
func (s Wildcard) AsExpression() Expression
func (Wildcard) AsSelectItem ¶
func (s Wildcard) AsSelectItem() SelectItem
type Window ¶
type Window struct {
PartitionBy []Expression
OrderBy []OrderBy
WindowFrame *WindowFrame
}
type WindowFrame ¶
type WindowFrame struct {
Unit WindowFrameUnit
StartBoundary WindowFrameBoundary
EndBoundary *WindowFrameBoundary
}
type WindowFrameBoundary ¶
type WindowFrameBoundary struct {
BoundaryType WindowFrameBoundaryType
BoundaryLiteral *Literal
}
type WindowFrameBoundaryType ¶
type WindowFrameBoundaryType int
const ( WindowFrameBoundaryTypeCurrentRow WindowFrameBoundaryType = iota WindowFrameBoundaryTypePreceding WindowFrameBoundaryTypeFollowing )
type WindowFrameUnit ¶
type WindowFrameUnit int
const ( WindowFrameUnitRows WindowFrameUnit = iota WindowFrameUnitRange WindowFrameUnitGroups )
type With ¶
type With struct {
Recursive bool
Expressions []CommonTableExpression
}
With is a statement that provides a way to write auxiliary statements for use in a larger query.
type WrappedNode ¶
type WrappedNode interface {
SyntaxNode
}
WrappedNode is an interface that allows for an expression to be wrapped to allow for side effects like futures.