utils

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 2 Imported by: 0

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

func ExprToString(expr ast.Expr, params map[string]interface{}) string

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

func ExprToValue(expr ast.Expr, params map[string]interface{}) interface{}

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.

Jump to

Keyboard shortcuts

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