Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to combine query sets using binary operators #127

Closed
ellmetha opened this issue Oct 27, 2023 · 0 comments
Closed

Make it possible to combine query sets using binary operators #127

ellmetha opened this issue Oct 27, 2023 · 0 comments
Assignees
Milestone

Comments

@ellmetha
Copy link
Member

Description

Sometimes it is necessary to combine the results of two distinct query sets. Presently it is not possible to do so without incurring two distinct SQL queries to the database.

To palliate this, let's add support for combining querysets by using the & and | operators. With this new capability, it would become possible to combine two query sets using those operators as follows:

Tag.filter(label: "foo") & Tag.filter(enabled: true)
Tag.filter(label: "foo") | Tag.filter(label: "bar")

In order to make this possible, we should implement the #& and #| methods at the Marten::DB::Query::Set abstraction level.

@ellmetha ellmetha changed the title Make it possible to combine querysets using binary operators Make it possible to combine query sets using binary operators Oct 27, 2023
@ellmetha ellmetha added this to the v0.5.0 milestone Jan 15, 2024
@ellmetha ellmetha self-assigned this Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant