Skip to content

Commit 97cbfce

Browse files
authored
Merge pull request #412 from isc-tdyar/fix/cypher-label-filter-truncation
fix(cypher): label-filtered edge traversal silently truncates at 10 results
2 parents 0618eaa + c43fc8d commit 97cbfce

2 files changed

Lines changed: 41 additions & 8 deletions

File tree

src/cypher/cypher.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4201,7 +4201,7 @@ static int execute_single(cbm_store_t *store, cbm_query_t *q, const char *projec
42014201
scan_pattern_nodes(store, project, max_rows, &pat0->nodes[0], &scanned, &scan_count);
42024202

42034203
/* Build initial bindings with early WHERE */
4204-
int bind_cap = scan_count > 0 ? scan_count : SKIP_ONE;
4204+
int bind_cap = scan_count > max_rows ? scan_count : (max_rows > 0 ? max_rows : SKIP_ONE);
42054205
binding_t *bindings = malloc((bind_cap + SKIP_ONE) * sizeof(binding_t));
42064206
int bind_count = 0;
42074207
const char *var_name = pat0->nodes[0].variable ? pat0->nodes[0].variable : "_n0";

tests/test_incremental.c

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ TEST(incr_modify_file) {
400400

401401
/* Single-file incremental should be faster than full */
402402
if ((int)ms > (int)(g_full_index_ms * 1.5)) {
403-
printf(" [PERF WARNING] incremental slower than 1.5x full: %.0fms vs %.0fms\n",
404-
ms, g_full_index_ms);
403+
printf(" [PERF WARNING] incremental slower than 1.5x full: %.0fms vs %.0fms\n", ms,
404+
g_full_index_ms);
405405
}
406406

407407
printf(" [perf] modify 1 file: %.0fms (full was %.0fms)\n", ms, g_full_index_ms);
@@ -910,12 +910,12 @@ static int resp_lacks_key(const char *resp, const char *key) {
910910
}
911911

912912
/* Helper: assert tool call succeeds, warn if slow */
913-
#define TOOL_OK(resp, ms) \
914-
do { \
915-
ASSERT((resp) != NULL); \
916-
if ((int)(ms) > PERF_WARN_MS) { \
913+
#define TOOL_OK(resp, ms) \
914+
do { \
915+
ASSERT((resp) != NULL); \
916+
if ((int)(ms) > PERF_WARN_MS) { \
917917
printf(" [PERF WARNING] tool call: %.0fms (>%dms)\n", (ms), PERF_WARN_MS); \
918-
} \
918+
} \
919919
} while (0)
920920

921921
/* Helper: assert response is not an error */
@@ -932,6 +932,38 @@ TEST(tool_list_projects_basic) {
932932
PASS();
933933
}
934934

935+
TEST(tool_qg_defines_method_more_than_10) {
936+
write_file_at("fastapi/big_class.py", "class BigClass:\n"
937+
" def m1(self): pass\n"
938+
" def m2(self): pass\n"
939+
" def m3(self): pass\n"
940+
" def m4(self): pass\n"
941+
" def m5(self): pass\n"
942+
" def m6(self): pass\n"
943+
" def m7(self): pass\n"
944+
" def m8(self): pass\n"
945+
" def m9(self): pass\n"
946+
" def m10(self): pass\n"
947+
" def m11(self): pass\n"
948+
" def m12(self): pass\n"
949+
" def m13(self): pass\n"
950+
" def m14(self): pass\n"
951+
" def m15(self): pass\n");
952+
char *idx = index_repo();
953+
ASSERT(idx != NULL);
954+
free(idx);
955+
double ms;
956+
char *r = call_tool_timed("query_graph", &ms,
957+
"{\"project\":\"%s\","
958+
"\"query\":\"MATCH (c:Class)-[:DEFINES_METHOD]->(m:Method)"
959+
" WHERE c.name = 'BigClass' RETURN count(m) AS n\"}",
960+
g_project);
961+
TOOL_OK(r, ms);
962+
ASSERT(strstr(r, "\"15\"") != NULL || strstr(r, "\\\"15\\\"") != NULL);
963+
free(r);
964+
PASS();
965+
}
966+
935967
TEST(tool_list_projects_has_current) {
936968
double ms;
937969
char *r = call_tool_timed("list_projects", &ms, "{}");
@@ -3042,6 +3074,7 @@ SUITE(incremental) {
30423074
RUN_TEST(tool_qg_configures);
30433075
RUN_TEST(tool_qg_handles);
30443076
RUN_TEST(tool_qg_defines_method);
3077+
RUN_TEST(tool_qg_defines_method_more_than_10);
30453078
RUN_TEST(tool_qg_no_limit);
30463079
RUN_TEST(tool_qg_empty_result);
30473080

0 commit comments

Comments
 (0)