| 3238 | /* ── Binding virtual variables (for WITH clause) ──────────────── */ |
| 3239 | |
| 3240 | static const char *binding_get_virtual(binding_t *b, const char *var, const char *prop) { |
| 3241 | if (!var) { |
| 3242 | return ""; |
| 3243 | } |
| 3244 | /* Check virtual vars first (from WITH projection) */ |
| 3245 | char full[CBM_SZ_256]; |
| 3246 | if (prop) { |
| 3247 | snprintf(full, sizeof(full), "%s.%s", var, prop); |
| 3248 | } else { |
| 3249 | snprintf(full, sizeof(full), "%s", var); |
| 3250 | } |
| 3251 | for (int i = 0; i < b->var_count; i++) { |
| 3252 | if (strcmp(b->var_names[i], full) == 0) { |
| 3253 | return b->var_nodes[i].name ? b->var_nodes[i].name : ""; |
| 3254 | } |
| 3255 | } |
| 3256 | /* Fall through to normal lookup */ |
| 3257 | cbm_edge_t *e = binding_get_edge(b, var); |
| 3258 | if (e) { |
| 3259 | /* Bare `RETURN r` on an edge: surface the full properties JSON |
| 3260 | * (or "{}" if none) so callers can inspect timestamps, weights, |
| 3261 | * etc. without naming each property. */ |
| 3262 | return prop ? edge_prop(e, prop) : (e->properties_json ? e->properties_json : "{}"); |
| 3263 | } |
| 3264 | cbm_node_t *n = binding_get(b, var); |
| 3265 | if (n) { |
| 3266 | if (prop) { |
| 3267 | return node_prop(n, prop, b->store); |
| 3268 | } |
| 3269 | return n->name ? n->name : ""; |
| 3270 | } |
| 3271 | return ""; |
| 3272 | } |
| 3273 | |
| 3274 | /* ── String function application ──────────────────────────────── */ |
| 3275 |
no test coverage detected