Documentation
¶
Overview ¶
Package utils provides utility functions for the Cypher query engine. It includes helper functions for converting AST expressions to values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExprToString ¶
ExprToString converts an AST expression to a string value. It handles string literals, identifiers, and other expression types by converting them to their string representation.
Parameters:
- expr: The AST expression to convert
- params: Query parameters for parameterized expressions
Returns the string representation of the expression, or an empty string if the expression is nil.
Example:
str := utils.ExprToString(&ast.StringLit{Value: "hello"}, nil)
// str == "hello"
str := utils.ExprToString(&ast.Ident{Name: "name"}, nil)
// str == "name"
func ExprToValue ¶
ExprToValue converts an AST expression to its corresponding Go value. It handles literal expressions (integers, floats, strings, booleans) and parameter references.
Parameters:
- expr: The AST expression to convert
- params: Query parameters for parameterized expressions
Returns the Go value represented by the expression, or nil if the expression is nil or of an unsupported type.
Example:
value := utils.ExprToValue(&ast.StringLit{Value: "hello"}, nil)
// value == "hello"
value := utils.ExprToValue(&ast.Param{Name: "name"}, map[string]interface{}{"name": "Alice"})
// value == "Alice"
Types ¶
This section is empty.