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

MONGOID-5608 allow using #exists? with args on relations #5736

Merged
merged 3 commits into from
Nov 2, 2023

Conversation

jamis
Copy link
Contributor

@jamis jamis commented Oct 30, 2023

Adds extended support for #exists? on embeds_many and has_many associations, so the API is the same as is present elsewhere in Mongoid, where the #exists? accepts conditions that can be used to narrow the scope of the query.

@jamis jamis requested a review from comandeo October 30, 2023 17:49
# @return [ true | false ] True is persisted documents exist, false if not.
def exists?
criteria.exists?
def exists?(id_or_conditions = :none)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not:

delegate :exists?, to: :criteria

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would work, too. In general I'm not a fan of that style. It tends to stymie investigation into execution flow, at least for me. I'll think about it, though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@comandeo comandeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
We have now tests for :none and Hash. Should we also add tests for nil and false ?

@jamis jamis merged commit 78fb959 into mongodb:master Nov 2, 2023
16 of 17 checks passed
@jamis jamis deleted the 5608-exists-with-args-on-relations branch November 2, 2023 16:00
jamis added a commit to jamis/mongoid that referenced this pull request Nov 2, 2023
)

* MONGOID-5608 allow using `#exists?` with args on relations

* simplify

* test the nil/false and _id matching paths, too
jamis added a commit to jamis/mongoid that referenced this pull request Nov 2, 2023
)

* MONGOID-5608 allow using `#exists?` with args on relations

* simplify

* test the nil/false and _id matching paths, too
jamis added a commit that referenced this pull request Nov 2, 2023
…5738)

* MONGOID-5608 allow using `#exists?` with args on relations

* simplify

* test the nil/false and _id matching paths, too
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants