Skip to content

Commit 9730b3a

Browse files
committed
query: use actual table id for IsA matches in fixed traversal
1 parent d279e43 commit 9730b3a

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

distr/flecs.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85789,10 +85789,10 @@ bool flecs_query_trav_fixed_src_up_fixed_second(
8578985789

8579085790
/* Check if table has transitive relationship by traversing upwards */
8579185791
ecs_table_record_t *tr = NULL;
85792-
ecs_search_relation(ctx->world, table, 0,
85793-
ecs_pair(trav, second), trav, EcsSelf|EcsUp, NULL, NULL, &tr);
85792+
const int32_t column = ecs_search_relation(ctx->world, table, 0,
85793+
ecs_pair(trav, second), trav, EcsSelf| EcsUp, NULL, NULL, &tr);
8579485794

85795-
if (!tr) {
85795+
if (column == -1 || !tr) {
8579685796
if (op->match_flags & EcsTermReflexive) {
8579785797
return flecs_query_trav_fixed_src_reflexive(op, ctx,
8579885798
&range, trav, second);
@@ -85801,7 +85801,17 @@ bool flecs_query_trav_fixed_src_up_fixed_second(
8580185801
}
8580285802
}
8580385803

85804-
flecs_query_set_trav_match(op, tr, trav, second, ctx);
85804+
ecs_id_t matched = ecs_pair(trav, second);
85805+
if (trav == EcsIsA) {
85806+
matched = table->type.array[column];
85807+
}
85808+
85809+
if (op->field_index != -1) {
85810+
ecs_iter_t *it = ctx->it;
85811+
it->ids [op->field_index] = matched;
85812+
flecs_query_it_set_tr(it, op->field_index, tr);
85813+
}
85814+
flecs_query_set_vars(op, matched, ctx);
8580585815
return true;
8580685816
}
8580785817

src/query/engine/eval_trav.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ bool flecs_query_trav_fixed_src_up_fixed_second(
9696

9797
/* Check if table has transitive relationship by traversing upwards */
9898
ecs_table_record_t *tr = NULL;
99-
ecs_search_relation(ctx->world, table, 0,
100-
ecs_pair(trav, second), trav, EcsSelf|EcsUp, NULL, NULL, &tr);
99+
const int32_t column = ecs_search_relation(ctx->world, table, 0,
100+
ecs_pair(trav, second), trav, EcsSelf| EcsUp, NULL, NULL, &tr);
101101

102-
if (!tr) {
102+
if (column == -1 || !tr) {
103103
if (op->match_flags & EcsTermReflexive) {
104104
return flecs_query_trav_fixed_src_reflexive(op, ctx,
105105
&range, trav, second);
@@ -108,7 +108,17 @@ bool flecs_query_trav_fixed_src_up_fixed_second(
108108
}
109109
}
110110

111-
flecs_query_set_trav_match(op, tr, trav, second, ctx);
111+
ecs_id_t matched = ecs_pair(trav, second);
112+
if (trav == EcsIsA) {
113+
matched = table->type.array[column];
114+
}
115+
116+
if (op->field_index != -1) {
117+
ecs_iter_t *it = ctx->it;
118+
it->ids [op->field_index] = matched;
119+
flecs_query_it_set_tr(it, op->field_index, tr);
120+
}
121+
flecs_query_set_vars(op, matched, ctx);
112122
return true;
113123
}
114124

0 commit comments

Comments
 (0)