Skip to content

Commit 5a53b11

Browse files
committed
fix: db.propertyKeys() returns Cypher property names, not column names
Changed to use property_mappings keys instead of column_names so that Neo4j Browser shows the correct Cypher property names that users can query with. Structural fields (from_id, to_id, edge_id) are not in property_mappings and correctly don't appear in the results.
1 parent e5ca181 commit 5a53b11

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/procedures/db_property_keys.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,40 @@
22
//!
33
//! Neo4j compatible procedure that lists all property keys across nodes and relationships.
44
//! Used by Neo4j Browser and Neodash to discover available properties.
5+
//!
6+
//! Returns Cypher property names (keys from property_mappings), NOT database column names.
57
68
use crate::graph_catalog::graph_schema::GraphSchema;
79
use std::collections::{HashMap, HashSet};
810

911
/// Execute db.propertyKeys() procedure
1012
///
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.
1216
///
1317
/// # Example Response
1418
/// ```json
1519
/// [
1620
/// {"propertyKey": "id"},
1721
/// {"propertyKey": "name"},
18-
/// {"propertyKey": "created_at"}
22+
/// {"propertyKey": "email"}
1923
/// ]
2024
/// ```
2125
pub fn execute(schema: &GraphSchema) -> Result<Vec<HashMap<String, serde_json::Value>>, String> {
2226
let mut keys = HashSet::new();
2327

24-
// Collect property keys from node schemas (use column names)
28+
// Collect Cypher property keys from node schemas (keys from property_mappings)
2529
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());
2832
}
2933
}
3034

31-
// Collect property keys from relationship schemas (use column names)
35+
// Collect Cypher property keys from relationship schemas (keys from property_mappings)
3236
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());
3539
}
3640
}
3741

0 commit comments

Comments
 (0)