bevyengine / bevyengine/bevy

Add more query join types (left, right, outer join)

Open
#13,633 14 comments 3 reactions 0 assignees View on GitHub
A-ECS C-Feature D-Complex S-Ready-For-Implementation X-Contentious
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
4d 8m
Merged PRs (30d)
147

Description

## What problem does this solve or what need does it fill?

The query join added in #11535 is useful, but only covers one of four common types of queries.

As discussed in #1658, these are:

1. Inner join: matches all entities that are found in both queries.
2. Outer join: matches all entities that are found in either query.
3. Left join: matches all entities that are found in the first query.
4. Right join: matches all entity

The join added in the PR above is an "inner join", which is useful and straightforward to implement.
However, this isn't always the desired behavior.

We should learn from the extensive history of database and implement this foundational functionality.

## What solution would you like?

Add the other join type methods, being clear that the base `join` is an inner join.

Data that is missing should be filled with `None`, and the fields that could be missing should be converted to their `Option` equivalents.

## What alternative(s) have you considered?

Maybe these join types aren't useful in practice in game dev and can just be omitted.

I had hoped that `Query::join` could take an extra parameter, the `JoinType` enum. However, I don't think that this is feasible, as the type returned varies based on the value based in. Perhaps a const generic would work, but that's blocked on https://github.com/rust-lang/rust/issues/95174 for now.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.