MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / project_item

Function project_item

src/cypher/cypher.c:4250–4339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4248}
4249
4250static const char *project_item(binding_t *b, cbm_return_item_t *item, char *func_buf,
4251 size_t buf_sz) {
4252 if (item->kase) {
4253 return eval_case_expr(item->kase, b);
4254 }
4255 if (item->args) {
4256 return eval_multiarg_func(b, item, func_buf, buf_sz);
4257 }
4258 /* Entity-introspection functions operate on the bound node/edge itself,
4259 * not on a scalar property value. */
4260 if (item->func) {
4261 if (strcmp(item->func, "labels") == 0) {
4262 cbm_node_t *n = binding_get(b, item->variable);
4263 if (n && n->label) {
4264 snprintf(func_buf, buf_sz, "[\"%s\"]", n->label);
4265 return func_buf;
4266 }
4267 return "[]";
4268 }
4269 if (strcmp(item->func, "type") == 0) {
4270 cbm_edge_t *e = binding_get_edge(b, item->variable);
4271 return (e && e->type) ? e->type : "";
4272 }
4273 if (strcmp(item->func, "id") == 0) {
4274 cbm_node_t *n = binding_get(b, item->variable);
4275 if (n) {
4276 snprintf(func_buf, buf_sz, "%lld", (long long)n->id);
4277 return func_buf;
4278 }
4279 cbm_edge_t *e = binding_get_edge(b, item->variable);
4280 if (e) {
4281 snprintf(func_buf, buf_sz, "%lld", (long long)e->id);
4282 return func_buf;
4283 }
4284 return "";
4285 }
4286 if (strcmp(item->func, "keys") == 0) {
4287 cbm_node_t *n = binding_get(b, item->variable);
4288 return n ? node_keys_list(n, func_buf, buf_sz) : "[]";
4289 }
4290 if (strcmp(item->func, "properties") == 0) {
4291 cbm_node_t *n = binding_get(b, item->variable);
4292 if (n) {
4293 return n->properties_json ? n->properties_json : "{}";
4294 }
4295 cbm_edge_t *e = binding_get_edge(b, item->variable);
4296 if (e) {
4297 return e->properties_json ? e->properties_json : "{}";
4298 }
4299 return "{}";
4300 }
4301 }
4302 const char *raw = binding_get_virtual(b, item->variable, item->property);
4303 if (is_scalar_value_func(item->func)) {
4304 return apply_string_func(item->func, raw, func_buf, buf_sz);
4305 }
4306 /* Direct node/edge fields live in the binding until this row has been
4307 * copied by rb_add_row. Keep those allocation-backed values intact: the

Callers 5

with_agg_build_keyFunction · 0.85
with_agg_find_or_createFunction · 0.85
execute_with_simpleFunction · 0.85
ret_agg_build_keyFunction · 0.85
ret_sink_feed_rowsFunction · 0.85

Calls 8

eval_case_exprFunction · 0.85
eval_multiarg_funcFunction · 0.85
binding_getFunction · 0.85
binding_get_edgeFunction · 0.85
node_keys_listFunction · 0.85
binding_get_virtualFunction · 0.85
is_scalar_value_funcFunction · 0.85
apply_string_funcFunction · 0.85

Tested by

no test coverage detected