Skip to content

Commit e0d6cca

Browse files
author
Your Name
committed
feat(cypher): resolve unknown properties from JSON properties_json
node_prop() previously returned empty string for any property not in the hardcoded column list (name, qualified_name, label, file_path, start_line, end_line). Now falls through to json_extract_prop() on the node's properties_json field for unknown properties. Enables Cypher queries like: WHERE n.is_entry_point = 'true' WHERE n.is_test = '1' WHERE n.confidence > '0.5' Also adds 'file' as an alias for 'file_path' and 'id' for the node ID. Tested: 'MATCH (n:Function) WHERE n.is_entry_point = true' returns 10 controller handlers (previously 0).
1 parent 0d05b0a commit e0d6cca

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/cypher/cypher.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,9 @@ typedef struct {
15611561
} binding_t;
15621562

15631563
/* Get node property by name */
1564+
/* Forward declaration — full implementation below */
1565+
static const char *json_extract_prop(const char *json, const char *key, char *buf, size_t buf_sz);
1566+
15641567
static const char *node_prop(const cbm_node_t *n, const char *prop) {
15651568
if (!n || !prop) {
15661569
return "";
@@ -1588,6 +1591,24 @@ static const char *node_prop(const cbm_node_t *n, const char *prop) {
15881591
snprintf(buf, sizeof(buf), "%d", n->end_line);
15891592
return buf;
15901593
}
1594+
if (strcmp(prop, "file") == 0) {
1595+
return n->file_path ? n->file_path : "";
1596+
}
1597+
if (strcmp(prop, "id") == 0) {
1598+
static char buf[32];
1599+
snprintf(buf, sizeof(buf), "%lld", (long long)n->id);
1600+
return buf;
1601+
}
1602+
/* Fall through to JSON properties for unknown fields.
1603+
* This enables queries like WHERE n.is_entry_point = true
1604+
* or WHERE n.confidence > 0.5 on properties stored in properties_json. */
1605+
if (n->properties_json) {
1606+
static char json_buf[1024];
1607+
const char *val = json_extract_prop(n->properties_json, prop, json_buf, sizeof(json_buf));
1608+
if (val && val[0]) {
1609+
return val;
1610+
}
1611+
}
15911612
return "";
15921613
}
15931614

0 commit comments

Comments
 (0)