diff --git a/planner/mapper/mapper.go b/planner/mapper/mapper.go index 0ea6b1b622..5a8f71eb54 100644 --- a/planner/mapper/mapper.go +++ b/planner/mapper/mapper.go @@ -370,6 +370,19 @@ func resolveAggregates( mapping.SetChildAt(index, childMapping) if !childIsMapped { + filterDependencies, err := resolveFilterDependencies( + ctx, + store, + childCollectionName, + target.filter, + mapping.ChildMappings[index], + childFields, + ) + if err != nil { + return nil, err + } + childFields = append(childFields, filterDependencies...) + // If the child was not mapped, the filter will not have been converted yet // so we must do that now. convertedFilter = ToFilter(target.filter.Value(), mapping.ChildMappings[index]) diff --git a/tests/integration/query/one_to_one/with_count_filter_test.go b/tests/integration/query/one_to_one/with_count_filter_test.go index a69be17f78..d5f2b60d22 100644 --- a/tests/integration/query/one_to_one/with_count_filter_test.go +++ b/tests/integration/query/one_to_one/with_count_filter_test.go @@ -16,8 +16,6 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -// This test documents a bug and should be altered with: -// https://github.com/sourcenetwork/defradb/issues/1869 func TestQueryOneToOneWithCountWithCompoundOrFilterThatIncludesRelation(t *testing.T) { test := testUtils.TestCase{ Description: "One-to-one relation with count with _or filter that includes relation", @@ -103,17 +101,12 @@ func TestQueryOneToOneWithCountWithCompoundOrFilterThatIncludesRelation(t *testi }`, Results: []map[string]any{ { - "_count": "2", + "_count": int(2), }, }, }, }, } - testUtils.AssertPanic( - t, - func() { - testUtils.ExecuteTestCase(t, test) - }, - ) + testUtils.ExecuteTestCase(t, test) }