Skip to content

Commit cbb2b5c

Browse files
Merge branch 'master' into MONGOID-5136-super-touch
2 parents aa148bd + eaa6d26 commit cbb2b5c

File tree

866 files changed

+771
-4132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

866 files changed

+771
-4132
lines changed

.evergreen/config.yml

Lines changed: 111 additions & 198 deletions
Large diffs are not rendered by default.

docs/reference/queries.txt

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,69 @@ the default scope being evaluated first:
987987
embedded: false>
988988

989989

990+
Pagination
991+
==========
992+
993+
Mongoid provides the pagination operators ``limit``, ``skip``, and ``batch_size`` on ``Criteria``.
994+
995+
.. _limit:
996+
997+
``limit``
998+
---------
999+
1000+
``limit`` sets the total number of documents to be returned by a query:
1001+
1002+
.. code-block:: ruby
1003+
1004+
Band.limit(5)
1005+
# =>
1006+
# #<Mongoid::Criteria
1007+
# selector: {}
1008+
# options: {:limit=>5}
1009+
# class: Band
1010+
# embedded: false>
1011+
1012+
.. _skip:
1013+
1014+
``skip``
1015+
--------
1016+
1017+
``skip`` (alias: ``offset``) sets the number of query results to skip
1018+
before returning documents. The ``limit`` value, if specified, will be applied
1019+
after documents are skipped. When performing pagination, ``skip`` is recommended
1020+
to be combined with :ref:`ordering <ordering>` to ensure consistent results.
1021+
1022+
.. code-block:: ruby
1023+
1024+
Band.skip(10)
1025+
# =>
1026+
# #<Mongoid::Criteria
1027+
# selector: {}
1028+
# options: {:skip=>10}
1029+
# class: Band
1030+
# embedded: false>
1031+
1032+
.. _batch-size:
1033+
1034+
``batch_size``
1035+
--------
1036+
1037+
When executing large queries, or when iterating over query results with an enumerator method such as
1038+
``Criteria#each``, Mongoid automatically uses the `MongoDB getMore command
1039+
<https://docs.mongodb.com/manual/reference/command/getMore/>`_ to load results in batches.
1040+
The default ``batch_size`` is 1000, however you may set it explicitly:
1041+
1042+
.. code-block:: ruby
1043+
1044+
Band.batch_size(500)
1045+
# =>
1046+
# #<Mongoid::Criteria
1047+
# selector: {}
1048+
# options: {:batch_size=>500}
1049+
# class: Band
1050+
# embedded: false>
1051+
1052+
9901053
.. _query-cache:
9911054

9921055
Query Cache
@@ -1551,6 +1614,11 @@ Mongoid supports persistence operations off of criteria
15511614
in a light capacity for when you want to expressively perform multi
15521615
document inserts, updates, and deletion.
15531616

1617+
.. warning::
1618+
1619+
Criteria ordering and pagination conditions, including ``order``, ``limit``,
1620+
``offset``, and ``batch_size``, will be ignored on the following operations.
1621+
15541622
.. list-table::
15551623
:header-rows: 1
15561624
:widths: 30 60

docs/release-notes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Release Notes
99
.. toctree::
1010
:titlesonly:
1111

12+
release-notes/mongoid-7.4
1213
release-notes/mongoid-7.3
1314
release-notes/mongoid-7.2
1415
release-notes/mongoid-7.1

docs/release-notes/mongoid-7.4.txt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
***********
2+
Mongoid 7.4
3+
***********
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
13+
This page describes significant changes and improvements in Mongoid 7.4.
14+
The complete list of releases is available `on GitHub
15+
<https://github.com/mongodb/mongoid/releases>`_ and `in JIRA
16+
<https://jira.mongodb.org/projects/MONGOID?selectedItem=com.atlassian.jira.jira-projects-plugin:release-page>`_;
17+
please consult GitHub releases for detailed release notes and JIRA for
18+
the complete list of issues fixed in each release, including bug fixes.
19+
20+
21+
``===`` Operator Matches Ruby Semantics
22+
---------------------------------------
23+
24+
**Breaking change:** In Mongoid 7.4, the ``===`` operator works the same way
25+
as it does in Ruby, and is equivalent to calling ``is_a?`` on the right hand
26+
side with the left hand side as the argument:
27+
28+
.. code-block:: ruby
29+
30+
ModelClass === instance
31+
32+
# equivalent to:
33+
instance.is_a?(ModelClass)
34+
35+
Previously, ``===`` returned ``true`` for some cases when the equivalent Ruby
36+
``===`` implementation returned false.
37+
38+
Mongoid 7.4 behavior:
39+
40+
.. code-block:: ruby
41+
42+
class Band
43+
include Mongoid::Document
44+
end
45+
46+
class CoverBand < Band
47+
end
48+
49+
band = Band.new
50+
cover_band = CoverBand.new
51+
52+
band === Band
53+
# => false
54+
55+
cover_band === Band
56+
# => false
57+
58+
Band === Band
59+
# => false
60+
61+
CoverBand === Band
62+
# => false
63+
64+
Mongoid 7.3 behavior:
65+
66+
.. code-block:: ruby
67+
68+
band === Band
69+
# => true
70+
71+
cover_band === Band
72+
# => true
73+
74+
Band === Band
75+
# => true
76+
77+
CoverBand === Band
78+
# => true
79+
80+
The standard invocation of ``===``, that is having the class on the left and
81+
the instance on the right, works the same in Mongoid 7.4 as it did previously
82+
and matches the core Ruby behavior:
83+
84+
.. code-block:: ruby
85+
86+
Band === band
87+
# => true
88+
89+
Band === cover_band
90+
# => true

examples/mongoid_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# frozen_string_literal: true
2-
# encoding: utf-8
32

43
require 'mongoid'
54
require 'mongoid/support/query_counter'

gemfiles/driver_oldstable.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source "https://rubygems.org"
22

3-
gem 'mongo', git: "https://github.com/mongodb/mongo-ruby-driver", branch: '2.13-stable'
3+
gem 'mongo', git: "https://github.com/mongodb/mongo-ruby-driver", branch: '2.14-stable'
44

55
gem 'actionpack'
66

gemfiles/driver_oldstable_jruby.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source "https://rubygems.org"
33
# Due to https://github.com/jruby/jruby/issues/5292 /
44
# https://github.com/bundler/bundler/issues/6678 we cannot test unreleased
55
# bson with JRuby, just test the driver then
6-
gem 'mongo', git: "https://github.com/mongodb/mongo-ruby-driver", branch: '2.13-stable'
6+
gem 'mongo', git: "https://github.com/mongodb/mongo-ruby-driver", branch: '2.14-stable'
77

88
gem 'actionpack'
99
# https://github.com/jruby/jruby/issues/6573

gemfiles/driver_stable.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source "https://rubygems.org"
22

3-
gem 'mongo', git: "https://github.com/mongodb/mongo-ruby-driver", branch: '2.14-stable'
3+
gem 'mongo', git: "https://github.com/mongodb/mongo-ruby-driver", branch: '2.15-stable'
44

55
gem 'actionpack'
66

gemfiles/driver_stable_jruby.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source "https://rubygems.org"
33
# Due to https://github.com/jruby/jruby/issues/5292 /
44
# https://github.com/bundler/bundler/issues/6678 we cannot test unreleased
55
# bson with JRuby, just test the driver then
6-
gem 'mongo', git: "https://github.com/mongodb/mongo-ruby-driver", branch: '2.14-stable'
6+
gem 'mongo', git: "https://github.com/mongodb/mongo-ruby-driver", branch: '2.15-stable'
77

88
gem 'actionpack'
99
# https://github.com/jruby/jruby/issues/6573

lib/config/locales/en.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ en:
8080
different collections so a simple id lookup is not sufficient enough."
8181
resolution: "Don't attempt to perform this action and have patience,
8282
maybe this will be supported in the future."
83+
empty_config_file:
84+
message: "Empty configuration file: %{path}."
85+
summary: "Your mongoid.yml configuration file appears to be empty."
86+
resolution: "Ensure your configuration file contains the correct contents.
87+
Please consult the following page with respect to Mongoid's configuration:
88+
https://docs.mongodb.com/mongoid/current/reference/configuration/"
8389
invalid_collection:
8490
message: "Access to the collection for %{klass} is not allowed."
8591
summary: "%{klass}.collection was called, and %{klass} is an embedded
@@ -94,6 +100,13 @@ en:
94100
A collation option is only supported if the query is executed on a MongoDB server
95101
with version >= 3.4."
96102
resolution: "Remove the collation option from the query."
103+
invalid_config_file:
104+
message: "Invalid configuration file: %{path}."
105+
summary: "Your mongoid.yml configuration file does not contain the
106+
correct file structure."
107+
resolution: "Ensure your configuration file contains the correct contents.
108+
Please consult the following page with respect to Mongoid's configuration:
109+
https://docs.mongodb.com/mongoid/current/reference/configuration/"
97110
invalid_config_option:
98111
message: "Invalid configuration option: %{name}."
99112
summary: "A invalid configuration option was provided in your

0 commit comments

Comments
 (0)