|
2 | 2 | //! |
3 | 3 | //! Neo4j compatible procedure that lists all property keys across nodes and relationships. |
4 | 4 | //! Used by Neo4j Browser and Neodash to discover available properties. |
| 5 | +//! |
| 6 | +//! Returns Cypher property names (keys from property_mappings), NOT database column names. |
5 | 7 |
|
6 | 8 | use crate::graph_catalog::graph_schema::GraphSchema; |
7 | 9 | use std::collections::{HashMap, HashSet}; |
8 | 10 |
|
9 | 11 | /// Execute db.propertyKeys() procedure |
10 | 12 | /// |
11 | | -/// Returns all unique property keys from both node and edge definitions. |
| 13 | +/// Returns all unique Cypher property keys from both node and edge definitions. |
| 14 | +/// These are the property names users can use in Cypher queries, not the underlying |
| 15 | +/// database column names. |
12 | 16 | /// |
13 | 17 | /// # Example Response |
14 | 18 | /// ```json |
15 | 19 | /// [ |
16 | 20 | /// {"propertyKey": "id"}, |
17 | 21 | /// {"propertyKey": "name"}, |
18 | | -/// {"propertyKey": "created_at"} |
| 22 | +/// {"propertyKey": "email"} |
19 | 23 | /// ] |
20 | 24 | /// ``` |
21 | 25 | pub fn execute(schema: &GraphSchema) -> Result<Vec<HashMap<String, serde_json::Value>>, String> { |
22 | 26 | let mut keys = HashSet::new(); |
23 | 27 |
|
24 | | - // Collect property keys from node schemas (use column names) |
| 28 | + // Collect Cypher property keys from node schemas (keys from property_mappings) |
25 | 29 | for node_schema in schema.all_node_schemas().values() { |
26 | | - for col in &node_schema.column_names { |
27 | | - keys.insert(col.clone()); |
| 30 | + for cypher_prop in node_schema.property_mappings.keys() { |
| 31 | + keys.insert(cypher_prop.clone()); |
28 | 32 | } |
29 | 33 | } |
30 | 34 |
|
31 | | - // Collect property keys from relationship schemas (use column names) |
| 35 | + // Collect Cypher property keys from relationship schemas (keys from property_mappings) |
32 | 36 | for rel_schema in schema.get_relationships_schemas().values() { |
33 | | - for col in &rel_schema.column_names { |
34 | | - keys.insert(col.clone()); |
| 37 | + for cypher_prop in rel_schema.property_mappings.keys() { |
| 38 | + keys.insert(cypher_prop.clone()); |
35 | 39 | } |
36 | 40 | } |
37 | 41 |
|
|
0 commit comments