-
Notifications
You must be signed in to change notification settings - Fork 1.4k
MONGOID-4998 deprecate :id_sort and implement limit positional argument on #first/#last #5358
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
Conversation
lib/mongoid/contextual/memory.rb
Outdated
def first(*args) | ||
eager_load([documents.first]).first | ||
def first(limit_or_opts = nil) | ||
if !limit_or_opts || limit_or_opts.is_a?(Hash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/mongoid/contextual/none.rb
Outdated
# @return [ nil ] Always nil. | ||
def last; nil; end | ||
def last(limit_or_opts = nil) | ||
if limit_or_opts && !limit_or_opts.is_a?(Hash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Co-authored-by: Oleg Pudeyev <39304720+p-mongo@users.noreply.github.com>
Co-authored-by: Oleg Pudeyev <39304720+p-mongo@users.noreply.github.com>
Co-authored-by: Oleg Pudeyev <39304720+p-mongo@users.noreply.github.com>
Co-authored-by: Oleg Pudeyev <39304720+p-mongo@users.noreply.github.com>
Co-authored-by: Oleg Pudeyev <39304720+p-mongo@users.noreply.github.com>
Co-authored-by: Oleg Pudeyev <39304720+p-mongo@users.noreply.github.com>
…nt on #first/#last (#5358) * MONGOID-4998 add limit to #first * MOGNOID-4998 add none implementation * MONGOID-4998 add caching and limit to last, fix first tests * MONGOID-4998 pass options through on memory, none, findable * MONGOID-4998 add last findable tests * Apply suggestions from code review * MONGOID-4998 add mongoid warning module * MONGOID-4998 make limit a positional argument * MONGOID-4998 update last signatures * MONGOID-4998 fix last sig * MONGOID-4998 fix mongo tests * MONGOID-4998 fix tests * MONGOID-4998 fix enumerable test * MONGOID-4998 add release note * MONGOID-4998 refactor numbered_cache * MONGOID-4998 add back id_sort functionality * MONGOID-4998 update queries.txt * MONGOID-4998 np docs * MONGOID-4998 fix test * Update docs/reference/queries.txt Co-authored-by: Oleg Pudeyev <39304720+p-mongo@users.noreply.github.com> * Update docs/reference/queries.txt Co-authored-by: Oleg Pudeyev <39304720+p-mongo@users.noreply.github.com> * Update docs/release-notes/mongoid-7.5.txt Co-authored-by: Oleg Pudeyev <39304720+p-mongo@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Oleg Pudeyev <39304720+p-mongo@users.noreply.github.com> * Update docs/release-notes/mongoid-7.5.txt Co-authored-by: Oleg Pudeyev <39304720+p-mongo@users.noreply.github.com> * Update lib/mongoid/warnings.rb Co-authored-by: Oleg Pudeyev <39304720+p-mongo@users.noreply.github.com> * MONGOID-4998 fix up suggestions * MONGOID-4998 use nil? * MONGOID-4998 use nil? on last Co-authored-by: Oleg Pudeyev <39304720+p-mongo@users.noreply.github.com>
PLEASE READ THIS before reviewing this PR. There's a lot going on here, and a lot still left to do.
First, this change is actually a few different changes wrapped in one (besides all of the #take stuff under it):
id_sort
optionlimit
optionThings still left to do:
Note that this PR should not be merged before that of MONGOID-4547, since this deprecation/removal of the id_none option only works once we have take. take provides the functionality that the id_none option did in first/last.
Future directives:
second
,third
etc.