pgsql

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 14 Imported by: 4

README

BloodHound PgSQL Model

This package contains a syntax model for the PostgreSQL SQL dialect. It also contains a translation implementation to take openCypher input and output valid PostgreSQL SQL. This model is not intended to be a complete implementation of all available SQL dialect features but rather the subset of the dialect required to perform openCypher to PostgreSQL translation.

Expected PostgreSQL SQL dialect version: 16.X

Formatting

The format package contains the string rendering logic for the PgSQL syntax model.

Translation

The translate package contains the openCypher translation implementation.

Optimization

The optimize package analyzes Cypher query shape before PostgreSQL SQL emission. See PostgreSQL Translation for optimizer coverage, indexing notes, and validation workflow.

Visualization

The visualization package contains a PUML digraph formatter for the PgSQL syntax model.

Test Cases

The test package contains the test cases used to validate translation.

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 DeletedPropertiesToString added in v0.4.12

func DeletedPropertiesToString(properties *graph.Properties) string

func IDSliceToInt8Array

func IDSliceToInt8Array(value []graph.ID) (pgtype.Int8Array, error)

func Int32SliceToInt4Array

func Int32SliceToInt4Array(value []int32) (pgtype.Int4Array, error)

func IsAggregateFunction

func IsAggregateFunction(function Identifier) bool

IsAggregateFunction reports whether function is one of the aggregate functions recognized by the SQL model.

func IsReservedIdentifier

func IsReservedIdentifier(identifier Identifier) bool

func JSONBToProperties

func JSONBToProperties(jsonb pgtype.JSONB) (*graph.Properties, error)

func MapStringAnyToJSONB

func MapStringAnyToJSONB(values map[string]any) (pgtype.JSONB, error)

func MatcherAsJSONB

func MatcherAsJSONB(fieldName string, value any) (pgtype.JSONB, error)

func MustMatcherAsJSONB

func MustMatcherAsJSONB(fieldName string, value any) pgtype.JSONB

func NegotiateValue

func NegotiateValue(value any) (any, error)

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

func StringSliceToTextArray(values []string) (pgtype.TextArray, error)

func ValueToJSONB

func ValueToJSONB(value any) (pgtype.JSONB, error)

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
	CastType   DataType
}

func (ArrayIndex) AsExpression

func (s ArrayIndex) AsExpression() Expression

func (ArrayIndex) NodeType

func (s ArrayIndex) NodeType() string

func (ArrayIndex) TypeHint added in v0.5.0

func (s ArrayIndex) TypeHint() DataType

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 ArraySlice added in v0.5.0

type ArraySlice struct {
	Expression Expression
	Lower      Expression
	Upper      Expression
	CastType   DataType
}

func (ArraySlice) AsExpression added in v0.5.0

func (s ArraySlice) AsExpression() Expression

func (ArraySlice) AsSelectItem added in v0.5.0

func (s ArraySlice) AsSelectItem() SelectItem

func (ArraySlice) NodeType added in v0.5.0

func (s ArraySlice) NodeType() string

func (ArraySlice) TypeHint added in v0.5.0

func (s ArraySlice) 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;

func (Case) AsExpression added in v0.5.0

func (s Case) AsExpression() Expression

func (Case) AsSelectItem added in v0.5.0

func (s Case) AsSelectItem() SelectItem

func (Case) NodeType added in v0.5.0

func (s Case) NodeType() string

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

func (CompositeValue) TypeHint added in v0.5.0

func (s CompositeValue) TypeHint() DataType

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 (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"
	PathEdge              DataType = "path_edge"
)

func ValueToDataType

func ValueToDataType(value any) (DataType, error)

func (DataType) ArrayBaseType

func (s DataType) ArrayBaseType() DataType

func (DataType) CoerceToSupertype

func (s DataType) CoerceToSupertype(other DataType) (DataType, bool)

CoerceToSupertype attempts to take the super of the type s and the type other

func (DataType) IsArrayType

func (s DataType) IsArrayType() bool

func (DataType) IsComparable

func (s DataType) IsComparable(other DataType, operator Operator) bool

func (DataType) IsKnown

func (s DataType) IsKnown() bool

func (DataType) IsTemporalType added in v0.5.0

func (s DataType) IsTemporalType() bool

func (DataType) MatchesOneOf

func (s DataType) MatchesOneOf(others ...DataType) bool

func (DataType) NodeType

func (s DataType) NodeType() string

func (DataType) OperatorResultType

func (s DataType) OperatorResultType(other DataType, operator Operator) (DataType, bool)

func (DataType) String

func (s DataType) String() string

func (DataType) TemporalIntervalArithmeticResultType added in v0.5.0

func (s DataType) TemporalIntervalArithmeticResultType() DataType

func (DataType) ToArrayType

func (s DataType) ToArrayType() (DataType, error)

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

func (s Delete) AsStatement() Statement

func (Delete) NodeType

func (s Delete) NodeType() string

type DoNothing

type DoNothing struct{}

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

func (DoUpdate) NodeType

func (s DoUpdate) NodeType() string

type EdgeArrayFromPathIDs added in v0.6.0

type EdgeArrayFromPathIDs struct {
	// PathIDs is the ordered edge-ID array to hydrate.
	PathIDs Expression
	// GraphID identifies the graph whose edge IDs are hydrated into edge composites.
	GraphID Expression
}

EdgeArrayFromPathIDs hydrates edge composites from a path's ordered edge identifiers.

func (*EdgeArrayFromPathIDs) AsExpression added in v0.6.0

func (s *EdgeArrayFromPathIDs) AsExpression() Expression

func (*EdgeArrayFromPathIDs) NodeType added in v0.6.0

func (s *EdgeArrayFromPathIDs) NodeType() string

type ExistsExpression

type ExistsExpression struct {
	Subquery Subquery
	Negated  bool
}

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

func OptionalParenthetical added in v0.6.0

func OptionalParenthetical(optional 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 omits the usual argument parentheses for SQL keyword-like functions.
	Bare bool
	// Distinct deduplicates argument rows before aggregate evaluation.
	Distinct bool
	// Function identifies the PostgreSQL function to invoke.
	Function Identifier
	// Parameters contains the function arguments in call order.
	Parameters []Expression
	// OrderBy orders aggregate inputs before the function is evaluated.
	OrderBy []*OrderBy
	// Over supplies the window specification for a window-function call.
	Over *Window
	// CastType records the function result type known to the translator.
	CastType DataType
}

FunctionCall represents a PostgreSQL function invocation and its aggregate or window options.

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 NewFuture

func NewFuture[U any](data U, dataType DataType) *Future[U]

func (Future[U]) AsExpression

func (s Future[U]) AsExpression() Expression

func (Future[U]) NodeType

func (s Future[U]) NodeType() string

func (Future[U]) Satisfied

func (s Future[U]) Satisfied() bool

func (Future[U]) TypeHint

func (s Future[U]) TypeHint() DataType

func (Future[U]) Unwrap

func (s Future[U]) Unwrap() SyntaxNode

type Identifier

type Identifier string
const (
	// FunctionUnidirectionalASPHarness identifies the SQL harness for unidirectional all-shortest-path search.
	FunctionUnidirectionalASPHarness Identifier = "unidirectional_asp_harness"

	// FunctionUnidirectionalSPHarness identifies the SQL harness for unidirectional single-shortest-path search.
	FunctionUnidirectionalSPHarness Identifier = "unidirectional_sp_harness"

	// FunctionBidirectionalASPHarness identifies the SQL harness for bidirectional all-shortest-path search.
	FunctionBidirectionalASPHarness Identifier = "bidirectional_asp_harness"

	// FunctionBidirectionalSPHarness identifies the SQL harness for bidirectional single-shortest-path search.
	FunctionBidirectionalSPHarness Identifier = "bidirectional_sp_harness"

	// FunctionAllShortestPathsDAG identifies the SQL helper that materializes every shortest path from a predecessor DAG.
	FunctionAllShortestPathsDAG Identifier = "all_shortest_paths_dag"

	// FunctionAllShortestPathsNoPathProbe identifies the bounded target-side
	// reachability preflight. It returns an exact empty result only after the
	// reverse component is exhausted; every positive or capped probe delegates
	// to the A1 predecessor-DAG helper.
	FunctionAllShortestPathsNoPathProbe Identifier = "all_shortest_paths_no_path_probe"

	// FunctionShortestPathCompact identifies the SQL helper that materializes one compact shortest-path witness.
	FunctionShortestPathCompact Identifier = "shortest_path_compact"

	// FunctionShortestPathB1StrictAlternating identifies compact bidirectional search with strict node alternation.
	FunctionShortestPathB1StrictAlternating Identifier = "shortest_path_b1_strict_alternating"

	// FunctionShortestPathB2SmallerCurrentLevel identifies compact bidirectional search that expands the smaller current level.
	FunctionShortestPathB2SmallerCurrentLevel Identifier = "shortest_path_b2_smaller_current_level"

	// FunctionAllShortestPathsB1StrictAlternating identifies two-sided predecessor-DAG enumeration with strict node alternation.
	FunctionAllShortestPathsB1StrictAlternating Identifier = "all_shortest_paths_b1_strict_alternating"

	// FunctionAllShortestPathsB2SmallerCurrentLevel identifies two-sided predecessor-DAG enumeration that expands the smaller current level.
	FunctionAllShortestPathsB2SmallerCurrentLevel Identifier = "all_shortest_paths_b2_smaller_current_level"

	// FunctionShortestPathSelfEndpointError identifies the SQL helper that raises an invalid self-endpoint error.
	FunctionShortestPathSelfEndpointError Identifier = "shortest_path_self_endpoint_error"

	// FunctionIntArrayUnique identifies the SQL helper that removes duplicate integer-array values.
	FunctionIntArrayUnique Identifier = "uniq"

	// FunctionIntArraySort identifies the SQL helper that orders integer-array values.
	FunctionIntArraySort Identifier = "sort"

	// FunctionJSONBToTextArray identifies the SQL helper that converts a JSONB array to text[].
	FunctionJSONBToTextArray Identifier = "jsonb_to_text_array"

	// FunctionJSONBArrayElementsText identifies PostgreSQL's JSONB array-element text expansion function.
	FunctionJSONBArrayElementsText Identifier = "jsonb_array_elements_text"

	// FunctionJSONBBuildObject identifies PostgreSQL's JSONB object constructor.
	FunctionJSONBBuildObject Identifier = "jsonb_build_object"

	// FunctionJSONBBuildArray constructs an array without reinterpreting element types.
	FunctionJSONBBuildArray Identifier = "jsonb_build_array"

	// FunctionJSONBArrayElements expands JSON arrays while preserving element types.
	FunctionJSONBArrayElements Identifier = "jsonb_array_elements"

	// FunctionJSONBArrayLength identifies PostgreSQL's JSONB array-length function.
	FunctionJSONBArrayLength Identifier = "jsonb_array_length"

	// FunctionJSONBTypeof identifies PostgreSQL's JSONB type-inspection function.
	FunctionJSONBTypeof Identifier = "jsonb_typeof"

	// FunctionToJSONB identifies PostgreSQL's conversion to JSONB.
	FunctionToJSONB Identifier = "to_jsonb"

	// FunctionTrunc removes the fractional part without rounding.
	FunctionTrunc Identifier = "trunc"

	// FunctionCypherText extracts a runtime string or explicitly converts a scalar.
	FunctionCypherText Identifier = "cypher_text"

	// FunctionCharLength counts Unicode characters in a string.
	FunctionCharLength Identifier = "char_length"

	// FunctionCypherList validates a runtime list without changing element types.
	FunctionCypherList Identifier = "cypher_list"

	// FunctionCypherSize returns the length of a runtime string or list.
	FunctionCypherSize Identifier = "cypher_size"

	// FunctionCypherCompare compares compatible runtime values, returning null for unlike types.
	FunctionCypherCompare Identifier = "cypher_compare"

	// FunctionCypherArithmetic evaluates arithmetic using the runtime JSON value types.
	FunctionCypherArithmetic Identifier = "cypher_arithmetic"

	// FunctionCypherContains identifies the SQL helper implementing Cypher CONTAINS semantics.
	FunctionCypherContains Identifier = "cypher_contains"

	// FunctionCypherStartsWith identifies the SQL helper implementing Cypher STARTS WITH semantics.
	FunctionCypherStartsWith Identifier = "cypher_starts_with"

	// FunctionCypherEndsWith identifies the SQL helper implementing Cypher ENDS WITH semantics.
	FunctionCypherEndsWith Identifier = "cypher_ends_with"

	// FunctionCypherMin identifies the SQL aggregate implementing Cypher minimum semantics.
	FunctionCypherMin Identifier = "cypher_min"

	// FunctionCypherMax identifies the SQL aggregate implementing Cypher maximum semantics.
	FunctionCypherMax Identifier = "cypher_max"

	// FunctionCypherSum sums runtime numbers without converting integers to floats.
	FunctionCypherSum Identifier = "cypher_sum"

	// FunctionArrayLength identifies PostgreSQL's dimension-aware array-length function.
	FunctionArrayLength Identifier = "array_length"

	// FunctionCardinality identifies PostgreSQL's total array-element count function.
	FunctionCardinality Identifier = "cardinality"

	// FunctionArrayAggregate identifies PostgreSQL's array aggregation function.
	FunctionArrayAggregate Identifier = "array_agg"

	// FunctionArrayRemove identifies PostgreSQL's array element-removal function.
	FunctionArrayRemove Identifier = "array_remove"

	// FunctionMin identifies PostgreSQL's minimum aggregate.
	FunctionMin Identifier = "min"

	// FunctionMax identifies PostgreSQL's maximum aggregate.
	FunctionMax Identifier = "max"

	// FunctionSum identifies PostgreSQL's sum aggregate.
	FunctionSum Identifier = "sum"

	// FunctionAvg identifies PostgreSQL's average aggregate.
	FunctionAvg Identifier = "avg"

	// FunctionLocalTimestamp identifies PostgreSQL's local timestamp constructor.
	FunctionLocalTimestamp Identifier = "localtimestamp"

	// FunctionLocalTime identifies PostgreSQL's local time constructor.
	FunctionLocalTime Identifier = "localtime"

	// FunctionCurrentTime identifies PostgreSQL's current zoned time value.
	FunctionCurrentTime Identifier = "current_time"

	// FunctionCurrentDate identifies PostgreSQL's current date value.
	FunctionCurrentDate Identifier = "current_date"

	// FunctionNow identifies PostgreSQL's current transaction timestamp function.
	FunctionNow Identifier = "now"

	// FunctionToLower identifies PostgreSQL's lowercase text function.
	FunctionToLower Identifier = "lower"

	// FunctionToUpper identifies PostgreSQL's uppercase text function.
	FunctionToUpper Identifier = "upper"

	// FunctionCoalesce identifies PostgreSQL's first-non-null expression.
	FunctionCoalesce Identifier = "coalesce"

	// FunctionNullIf identifies PostgreSQL's NULLIF function for nulling matching scalar values.
	FunctionNullIf Identifier = "nullif"

	// FunctionReplace identifies PostgreSQL's substring-replacement function.
	FunctionReplace Identifier = "replace"

	// FunctionUnnest identifies PostgreSQL's array-to-row expansion function.
	FunctionUnnest Identifier = "unnest"

	// FunctionNextValue identifies PostgreSQL's sequence increment function.
	FunctionNextValue Identifier = "nextval"

	// FunctionPGGetSerialSequence identifies PostgreSQL's serial-sequence lookup function.
	FunctionPGGetSerialSequence Identifier = "pg_get_serial_sequence"

	// FunctionJSONBSet identifies PostgreSQL's JSONB path-update function.
	FunctionJSONBSet Identifier = "jsonb_set"

	// FunctionCount identifies PostgreSQL's count aggregate.
	FunctionCount Identifier = "count"

	// FunctionStringToArray identifies PostgreSQL's delimiter-based text-to-array function.
	FunctionStringToArray Identifier = "string_to_array"

	// FunctionEdgesToPath identifies the SQL helper that builds a path from unordered edge composites.
	FunctionEdgesToPath Identifier = "edges_to_path"

	// FunctionOrderedEdgesToPath identifies the SQL helper that builds a path from ordered edge composites.
	FunctionOrderedEdgesToPath Identifier = "ordered_edges_to_path"

	// FunctionOrderedEdgeIDsToPath identifies the SQL helper that hydrates an ordered edge-ID array into a path.
	FunctionOrderedEdgeIDsToPath Identifier = "ordered_edge_ids_to_path"

	// FunctionNodesToPath identifies the SQL helper that builds a path from ordered node composites.
	FunctionNodesToPath Identifier = "nodes_to_path"

	// FunctionKindName identifies the SQL helper that resolves a kind ID to its name.
	FunctionKindName Identifier = "kind_name"

	// FunctionStartNode identifies the SQL helper that hydrates a relationship's start node.
	FunctionStartNode Identifier = "start_node"

	// FunctionEndNode identifies the SQL helper that hydrates a relationship's end node.
	FunctionEndNode Identifier = "end_node"

	// FunctionExtract identifies PostgreSQL's temporal component-extraction function.
	FunctionExtract Identifier = "extract"

	// FunctionGenerateSubscripts identifies PostgreSQL's array-index generation function.
	FunctionGenerateSubscripts Identifier = "generate_subscripts"
	FunctionCypherLikeEscape   Identifier = "cypher_like_escape"
)
const (
	WildcardIdentifier Identifier = "*"
	EpochIdentifier    Identifier = "epoch"
)
const (
	StringLiteralNull       = "null"
	StringLiteralEmptyArray = "[]"

	TableNode Identifier = "node"
	TableEdge Identifier = "edge"
	TableKind Identifier = "kind"

	ColumnID         Identifier = "id"
	ColumnName       Identifier = "name"
	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"
	ColumnNodes      Identifier = "nodes"
	ColumnEdges      Identifier = "edges"
)

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) AsExpression added in v0.5.0

func (s Insert) AsExpression() Expression

func (Insert) AsSetExpression added in v0.5.0

func (s Insert) AsSetExpression() SetExpression

func (Insert) AsStatement

func (s Insert) AsStatement() Statement

func (Insert) NodeType

func (s Insert) NodeType() string

type Join

type Join struct {
	Table        Expression
	JoinOperator JoinOperator
}

func (Join) NodeType

func (s Join) NodeType() string

type JoinOperator

type JoinOperator struct {
	JoinType   JoinType
	Constraint Expression
}

func (JoinOperator) NodeType

func (s JoinOperator) NodeType() string

type JoinType

type JoinType int
const (
	// JoinTypeInner retains rows that satisfy the join constraint on both sides.
	JoinTypeInner JoinType = iota

	// JoinTypeLeftOuter retains every left row even when no right row matches.
	JoinTypeLeftOuter

	// JoinTypeRightOuter retains every right row even when no left row matches.
	JoinTypeRightOuter

	// JoinTypeFullOuter retains unmatched rows from both sides.
	JoinTypeFullOuter
)

type KindListLiteral

type KindListLiteral struct {
	Values graph.Kinds
}

func (KindListLiteral) AsExpression

func (s KindListLiteral) AsExpression() Expression

func (KindListLiteral) NodeType

func (s KindListLiteral) NodeType() string

type KindMapper

type KindMapper interface {
	// MapKinds returns MissingKindsError for authoritative misses. Other errors
	// remain execution failures, including when translating match predicates.
	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 LateralSubquery added in v0.5.0

type LateralSubquery struct {
	Query   Query
	Binding models.Optional[Identifier]
}

func (LateralSubquery) AsExpression added in v0.5.0

func (s LateralSubquery) AsExpression() Expression

func (LateralSubquery) NodeType added in v0.5.0

func (s LateralSubquery) NodeType() string

type Literal

type Literal struct {
	Value    any
	Null     bool
	CastType DataType
}

Literal is a type-hinted literal SQL value.

func AsLiteral

func AsLiteral(value any) (Literal, error)

func NewLiteral

func NewLiteral(value any, dataType DataType) Literal

func NullLiteral

func NullLiteral() Literal

func (Literal) AsExpression

func (s Literal) AsExpression() Expression

func (Literal) AsSelectItem

func (s Literal) AsSelectItem() SelectItem

func (Literal) NodeType

func (s Literal) NodeType() string

func (Literal) TypeHint

func (s Literal) TypeHint() DataType

type LiteralNodeValue

type LiteralNodeValue struct {
	Value    any
	Null     bool
	CastType DataType
}

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

func (s Merge) AsStatement() Statement

func (Merge) NodeType

func (s Merge) NodeType() string

type MergeAction

type MergeAction interface {
	Expression
	AsMergeAction() MergeAction
}

MergeAction is an expression that can be used as the action of a merge statement.

type MissingKindsError added in v1.0.0

type MissingKindsError struct {
	Kinds   graph.Kinds
	KindIDs []int16
}

MissingKindsError reports an authoritative lookup miss after any cache refresh. KindIDs contains only the resolved kinds, in input order. Callers requiring all kinds must still treat this as an error; match translation can apply AND/OR semantics.

func (*MissingKindsError) Error added in v1.0.0

func (s *MissingKindsError) Error() string

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.&&)"
	OperatorPGArrayLHSContainsRHS 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 = "+="
	OperatorIsDistinctFrom        Operator = "is distinct from"
	OperatorIsNotDistinctFrom     Operator = "is not distinct from"

	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

func (Operator) IsIn

func (s Operator) IsIn(others ...Operator) bool

func (Operator) NodeType

func (s Operator) NodeType() string

func (Operator) String

func (s Operator) String() string

type OrderBy

type OrderBy struct {
	Expression Expression
	Ascending  bool
}

func NewOrderBy

func NewOrderBy(ascending bool) *OrderBy

func (OrderBy) AsExpression

func (s OrderBy) AsExpression() Expression

func (OrderBy) NodeType

func (s OrderBy) NodeType() string

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

func (Parameter) NodeType

func (s Parameter) NodeType() string

func (Parameter) TypeHint

func (s Parameter) TypeHint() DataType

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 PropertyKey added in v0.9.0

type PropertyKey struct {
	Literal Literal
}

func (PropertyKey) AsExpression added in v0.9.0

func (s PropertyKey) AsExpression() Expression

func (PropertyKey) NodeType added in v0.9.0

func (s PropertyKey) 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

func (s Query) AsStatement() Statement

func (Query) NodeType

func (s Query) NodeType() string

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

func (Select) NodeType

func (s Select) NodeType() string

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

func (Subquery) NodeType

func (s Subquery) NodeType() string

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

func (TypeCast) AsSelectItem added in v0.5.0

func (s TypeCast) AsSelectItem() SelectItem

func (TypeCast) NodeType

func (s TypeCast) NodeType() string

func (TypeCast) TypeHint

func (s TypeCast) TypeHint() DataType

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) AsSelectItem added in v1.0.0

func (s UnaryExpression) AsSelectItem() SelectItem

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

func (s Update) AsStatement() Statement

func (Update) NodeType

func (s Update) NodeType() string

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

func (Values) NodeType

func (s Values) NodeType() string

type Variadic

type Variadic struct {
	Expression Expression
}

Variadic isrepresents a variadic expansion of the given expression.

func (Variadic) AsExpression

func (s Variadic) AsExpression() Expression

func (Variadic) NodeType

func (s Variadic) NodeType() string

type Wildcard

type Wildcard struct{}

func (Wildcard) AsExpression

func (s Wildcard) AsExpression() Expression

func (Wildcard) AsSelectItem

func (s Wildcard) AsSelectItem() SelectItem

func (Wildcard) NodeType

func (s Wildcard) NodeType() string

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 anchors a window boundary at the current row or peer group.
	WindowFrameBoundaryTypeCurrentRow WindowFrameBoundaryType = iota

	// WindowFrameBoundaryTypePreceding places a window boundary before the current row.
	WindowFrameBoundaryTypePreceding

	// WindowFrameBoundaryTypeFollowing places a window boundary after the current row.
	WindowFrameBoundaryTypeFollowing
)

type WindowFrameUnit

type WindowFrameUnit int
const (
	// WindowFrameUnitRows measures frame boundaries in physical rows.
	WindowFrameUnitRows WindowFrameUnit = iota

	// WindowFrameUnitRange measures frame boundaries by ordering-key value ranges.
	WindowFrameUnitRange

	// WindowFrameUnitGroups measures frame boundaries in peer groups.
	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.

func (With) NodeType

func (s With) NodeType() string

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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