Expand SELECT items, handling wildcard (*) by creating return items for all node properties
(
&self,
select_items: &SelectItems,
graph: &Arc<GraphCache>,
)
| 8484 | |
| 8485 | /// Expand SELECT items, handling wildcard (*) by creating return items for all node properties |
| 8486 | fn expand_select_items( |
| 8487 | &self, |
| 8488 | select_items: &SelectItems, |
| 8489 | graph: &Arc<GraphCache>, |
| 8490 | ) -> Result<Vec<ReturnItem>, ExecutionError> { |
| 8491 | match select_items { |
| 8492 | SelectItems::Explicit { items, .. } => Ok(items.clone()), |
| 8493 | SelectItems::Wildcard { .. } => { |
| 8494 | // For wildcard, we need to determine what properties are available |
| 8495 | // This is a simplified implementation - in a full implementation, |
| 8496 | // we'd analyze the query to determine available variables and their properties |
| 8497 | // Since graph is Arc<GraphCache>, we can access it directly |
| 8498 | |
| 8499 | // Get all unique property names from all nodes |
| 8500 | let mut property_names = std::collections::BTreeSet::new(); |
| 8501 | for node in graph.get_all_nodes() { |
| 8502 | for prop_name in node.properties.keys() { |
| 8503 | property_names.insert(prop_name.clone()); |
| 8504 | } |
| 8505 | } |
| 8506 | |
| 8507 | // Create return items for each unique property |
| 8508 | let mut return_items = Vec::new(); |
| 8509 | |
| 8510 | // Add node variable itself (assuming 'm' from the pattern) |
| 8511 | return_items.push(ReturnItem { |
| 8512 | expression: Expression::Variable(Variable { |
| 8513 | name: "m".to_string(), |
| 8514 | location: Location::default(), |
| 8515 | }), |
| 8516 | alias: None, |
| 8517 | location: Location::default(), |
| 8518 | }); |
| 8519 | |
| 8520 | // Add each property as m.property_name |
| 8521 | for prop_name in property_names { |
| 8522 | return_items.push(ReturnItem { |
| 8523 | expression: Expression::PropertyAccess(PropertyAccess { |
| 8524 | object: "m".to_string(), |
| 8525 | property: prop_name, |
| 8526 | location: Location::default(), |
| 8527 | }), |
| 8528 | alias: None, |
| 8529 | location: Location::default(), |
| 8530 | }); |
| 8531 | } |
| 8532 | |
| 8533 | Ok(return_items) |
| 8534 | } |
| 8535 | } |
| 8536 | } |
| 8537 | |
| 8538 | /// Execute DECLARE statement to define local variables with type specifications |
| 8539 | /// Internal method for declare statements |
no test coverage detected