MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / try_convert_value_to_node

Method try_convert_value_to_node

graphlite/src/exec/executor.rs:1731–1774  ·  view source on GitHub ↗

Try to convert a value to a Node (simplified heuristic)

(
        &self,
        _key: &str,
        value: &crate::storage::Value,
    )

Source from the content-addressed store, hash-verified

1729
1730 /// Try to convert a value to a Node (simplified heuristic)
1731 fn try_convert_value_to_node(
1732 &self,
1733 _key: &str,
1734 value: &crate::storage::Value,
1735 ) -> Result<crate::storage::Node, ExecutionError> {
1736 use crate::storage::{Node, Value};
1737 use std::collections::HashMap;
1738
1739 // Create a simple node from the value
1740 match value {
1741 Value::Node(node) => {
1742 // If the value is already a Node, return it directly (this fixes the WITH clause property access bug)
1743 Ok(node.clone())
1744 }
1745 Value::String(s) => {
1746 let mut properties = HashMap::new();
1747 properties.insert("id".to_string(), Value::String(s.clone()));
1748 Ok(Node {
1749 id: s.clone(),
1750 labels: vec![],
1751 properties,
1752 })
1753 }
1754 Value::Number(n) => {
1755 let mut properties = HashMap::new();
1756 properties.insert("id".to_string(), Value::Number(*n));
1757 Ok(Node {
1758 id: n.to_string(),
1759 labels: vec![],
1760 properties,
1761 })
1762 }
1763 _ => {
1764 // For non-string/number values, create a generic node
1765 let mut properties = HashMap::new();
1766 properties.insert("value".to_string(), value.clone());
1767 Ok(Node {
1768 id: format!("{:?}", value),
1769 labels: vec![],
1770 properties,
1771 })
1772 }
1773 }
1774 }
1775
1776 /// Convert WithClauseResult back to Row format
1777 fn convert_processor_result_to_rows(

Callers 1

Calls 2

cloneMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected