Skip to content

Commit d418c20

Browse files
committed
Fix filter.sub() expanding cardinality in _1-Many_ relationships
1 parent ea9aca1 commit d418c20

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/core/database/query/filters.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,11 @@ export const sub =
234234
sub
235235
.apply(matchSubNode)
236236
.apply(subBuilder()(value))
237-
.return(`true as ${key}FiltersApplied`),
237+
.return(`true as ${key}FiltersApplied`)
238+
// Prevent filter from increasing cardinality above 1.
239+
// This happens with `1-Many` relationships matched in `matchSubNode`.
240+
// Note they are allowed to reduce cardinality to 0.
241+
.raw('limit 1'),
238242
)
239243
.with('*');
240244

0 commit comments

Comments
 (0)