mongoid 9.0.10 → 9.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/Rakefile +31 -0
- data/lib/config/locales/en.yml +45 -0
- data/lib/mongoid/association/depending.rb +8 -4
- data/lib/mongoid/association/nested/many.rb +38 -3
- data/lib/mongoid/association/nested/nested_buildable.rb +14 -0
- data/lib/mongoid/association/referenced/auto_save.rb +48 -6
- data/lib/mongoid/association/referenced/has_many/proxy.rb +100 -1
- data/lib/mongoid/association/relatable.rb +17 -0
- data/lib/mongoid/collection_configurable.rb +8 -0
- data/lib/mongoid/config/defaults.rb +9 -5
- data/lib/mongoid/config/encryption.rb +36 -18
- data/lib/mongoid/config.rb +72 -0
- data/lib/mongoid/contextual/aggregable/memory.rb +5 -2
- data/lib/mongoid/contextual/memory.rb +18 -7
- data/lib/mongoid/criteria/queryable/mergeable.rb +4 -0
- data/lib/mongoid/criteria/queryable/selectable.rb +109 -0
- data/lib/mongoid/encryptable.rb +46 -0
- data/lib/mongoid/errors/in_memory_regexp_timeout.rb +26 -0
- data/lib/mongoid/errors/no_encryption_schema.rb +28 -0
- data/lib/mongoid/errors.rb +2 -0
- data/lib/mongoid/field_readable.rb +70 -0
- data/lib/mongoid/indexable.rb +39 -27
- data/lib/mongoid/matchable.rb +6 -1
- data/lib/mongoid/matcher/eq_impl_with_regexp.rb +4 -9
- data/lib/mongoid/matcher/regex.rb +9 -13
- data/lib/mongoid/matcher/regexp_budget.rb +383 -0
- data/lib/mongoid/matcher.rb +1 -0
- data/lib/mongoid/persistence_context.rb +35 -0
- data/lib/mongoid/search_indexable.rb +14 -7
- data/lib/mongoid/tasks/database.rb +23 -9
- data/lib/mongoid/threaded.rb +37 -0
- data/lib/mongoid/version.rb +1 -1
- data/lib/mongoid/warnings.rb +4 -0
- data/spec/integration/app_spec.rb +201 -36
- data/spec/integration/associations/has_and_belongs_to_many_spec.rb +17 -2
- data/spec/integration/dots_and_dollars_spec.rb +12 -2
- data/spec/integration/encryption_spec.rb +149 -0
- data/spec/integration/matcher_operator_data/regex.yml +21 -0
- data/spec/integration/matcher_regexp_timeout_spec.rb +215 -0
- data/spec/integration/query_operator_guard_spec.rb +89 -0
- data/spec/mongoid/association/auto_save_spec.rb +98 -0
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +48 -0
- data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +145 -0
- data/spec/mongoid/attributes/nested_spec.rb +250 -30
- data/spec/mongoid/config/defaults_spec.rb +18 -0
- data/spec/mongoid/config/encryption_spec.rb +228 -0
- data/spec/mongoid/contextual/aggregable/memory_spec.rb +91 -0
- data/spec/mongoid/contextual/memory_spec.rb +177 -0
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +2 -0
- data/spec/mongoid/criteria/queryable/selectable_where_spec.rb +200 -0
- data/spec/mongoid/criteria_spec.rb +2 -0
- data/spec/mongoid/encryptable_spec.rb +61 -0
- data/spec/mongoid/errors/document_not_found_spec.rb +10 -3
- data/spec/mongoid/matcher/regexp_budget_spec.rb +570 -0
- data/spec/mongoid/tasks/database_spec.rb +18 -0
- data/spec/support/crypt/models.rb +157 -0
- metadata +28 -2
|
@@ -47,4 +47,161 @@ module Crypt
|
|
|
47
47
|
field :vin, type: String, encrypt: true
|
|
48
48
|
field :make, type: String
|
|
49
49
|
end
|
|
50
|
+
|
|
51
|
+
# An encrypted model whose database name is a callable resolving to a
|
|
52
|
+
# constant. The callable form of :database is supported by store_in, but the
|
|
53
|
+
# encryption schema map is keyed by namespace and built once, so this model's
|
|
54
|
+
# namespace is not known when the map is generated.
|
|
55
|
+
class DynamicCar
|
|
56
|
+
include Mongoid::Document
|
|
57
|
+
|
|
58
|
+
store_in database: -> { 'vehicles_dynamic' }
|
|
59
|
+
|
|
60
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q==', deterministic: true
|
|
61
|
+
|
|
62
|
+
field :vin, type: String, encrypt: true
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# An encrypted model using the documented multi-tenant idiom, where the
|
|
66
|
+
# database name is only known once a tenant is selected. There is no correct
|
|
67
|
+
# value to resolve at client construction time.
|
|
68
|
+
class TenantCar
|
|
69
|
+
include Mongoid::Document
|
|
70
|
+
|
|
71
|
+
# The fallback keeps this model usable by tasks that iterate every model,
|
|
72
|
+
# such as Mongoid::Tasks::Database.create_collections. Mongoid raises
|
|
73
|
+
# NoMethodError when a callable :database resolves to nil.
|
|
74
|
+
store_in database: -> { Thread.current[:tenant_database] || 'vehicles_no_tenant' }
|
|
75
|
+
|
|
76
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q==', deterministic: true
|
|
77
|
+
|
|
78
|
+
field :vin, type: String, encrypt: true
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# An encrypted model that is embedded by more than one parent, and more than
|
|
82
|
+
# once by the same parent.
|
|
83
|
+
class Token
|
|
84
|
+
include Mongoid::Document
|
|
85
|
+
|
|
86
|
+
field :value, type: String, encrypt: { deterministic: true }
|
|
87
|
+
|
|
88
|
+
embedded_in :tokenized, polymorphic: true
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# A parent whose encrypted data lives entirely in an embedded model: it has
|
|
92
|
+
# no encrypted field of its own and no encrypt_with.
|
|
93
|
+
class Wallet
|
|
94
|
+
include Mongoid::Document
|
|
95
|
+
|
|
96
|
+
embeds_one :token, class_name: 'Crypt::Token', as: :tokenized
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Two parents embedding the same encrypted model.
|
|
100
|
+
class Vault
|
|
101
|
+
include Mongoid::Document
|
|
102
|
+
|
|
103
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q=='
|
|
104
|
+
|
|
105
|
+
embeds_one :token, class_name: 'Crypt::Token', as: :tokenized
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
class Chest
|
|
109
|
+
include Mongoid::Document
|
|
110
|
+
|
|
111
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q=='
|
|
112
|
+
|
|
113
|
+
embeds_one :token, class_name: 'Crypt::Token', as: :tokenized
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# A parent embedding the same encrypted model through two relations.
|
|
117
|
+
class Ledger
|
|
118
|
+
include Mongoid::Document
|
|
119
|
+
|
|
120
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q=='
|
|
121
|
+
|
|
122
|
+
embeds_one :primary_token, class_name: 'Crypt::Token', as: :tokenized
|
|
123
|
+
embeds_one :backup_token, class_name: 'Crypt::Token', as: :tokenized
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Three levels of nesting, where the middle level has no encrypted field of
|
|
127
|
+
# its own.
|
|
128
|
+
class Owner
|
|
129
|
+
include Mongoid::Document
|
|
130
|
+
|
|
131
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q=='
|
|
132
|
+
|
|
133
|
+
embeds_one :account, class_name: 'Crypt::Account'
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
class Account
|
|
137
|
+
include Mongoid::Document
|
|
138
|
+
|
|
139
|
+
embedded_in :owner, class_name: 'Crypt::Owner'
|
|
140
|
+
embeds_one :credential, class_name: 'Crypt::Credential'
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
class Credential
|
|
144
|
+
include Mongoid::Document
|
|
145
|
+
|
|
146
|
+
field :secret, type: String, encrypt: { deterministic: true }
|
|
147
|
+
|
|
148
|
+
embedded_in :account, class_name: 'Crypt::Account'
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# A model that embeds itself. The walk over embedded relations has to stop
|
|
152
|
+
# here, or generating the map never terminates.
|
|
153
|
+
class Comment
|
|
154
|
+
include Mongoid::Document
|
|
155
|
+
|
|
156
|
+
field :body, type: String, encrypt: { deterministic: true }
|
|
157
|
+
|
|
158
|
+
embedded_in :commentable, polymorphic: true
|
|
159
|
+
embeds_one :reply, class_name: 'Crypt::Comment', as: :commentable
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
class Article
|
|
163
|
+
include Mongoid::Document
|
|
164
|
+
|
|
165
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q=='
|
|
166
|
+
|
|
167
|
+
embeds_one :comment, class_name: 'Crypt::Comment', as: :commentable
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# A parent with no encrypted field of its own: the encrypted field lives on
|
|
171
|
+
# the embedded model. Used by the integration specs, so the embedded model
|
|
172
|
+
# carries a key id.
|
|
173
|
+
class Folder
|
|
174
|
+
include Mongoid::Document
|
|
175
|
+
|
|
176
|
+
embeds_one :note, class_name: 'Crypt::Note'
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
class Note
|
|
180
|
+
include Mongoid::Document
|
|
181
|
+
|
|
182
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q==', deterministic: true
|
|
183
|
+
|
|
184
|
+
field :text, type: String, encrypt: true
|
|
185
|
+
|
|
186
|
+
embedded_in :folder, class_name: 'Crypt::Folder'
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# A model naming an embedded class that is never defined. The association
|
|
190
|
+
# cannot be used, so nothing is ever embedded through it, but every model in
|
|
191
|
+
# the application is walked when the schema map is generated.
|
|
192
|
+
class Drawer
|
|
193
|
+
include Mongoid::Document
|
|
194
|
+
|
|
195
|
+
embeds_one :missing_note, class_name: 'Crypt::MissingNote'
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# The same, on a model that is encrypted itself, so the walk descends into
|
|
199
|
+
# its relations.
|
|
200
|
+
class Cabinet
|
|
201
|
+
include Mongoid::Document
|
|
202
|
+
|
|
203
|
+
field :label, type: String, encrypt: { deterministic: true }
|
|
204
|
+
|
|
205
|
+
embeds_one :missing_note, class_name: 'Crypt::MissingNote'
|
|
206
|
+
end
|
|
50
207
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongoid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 9.0.
|
|
4
|
+
version: 9.0.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- The MongoDB Ruby Team
|
|
@@ -75,6 +75,20 @@ dependencies:
|
|
|
75
75
|
- - "<"
|
|
76
76
|
- !ruby/object:Gem::Version
|
|
77
77
|
version: '2.0'
|
|
78
|
+
- !ruby/object:Gem::Dependency
|
|
79
|
+
name: ostruct
|
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
|
81
|
+
requirements:
|
|
82
|
+
- - ">="
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: '0'
|
|
85
|
+
type: :runtime
|
|
86
|
+
prerelease: false
|
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
78
92
|
- !ruby/object:Gem::Dependency
|
|
79
93
|
name: bson
|
|
80
94
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -278,6 +292,7 @@ files:
|
|
|
278
292
|
- lib/mongoid/errors/empty_config_file.rb
|
|
279
293
|
- lib/mongoid/errors/immutable_attribute.rb
|
|
280
294
|
- lib/mongoid/errors/in_memory_collation_not_supported.rb
|
|
295
|
+
- lib/mongoid/errors/in_memory_regexp_timeout.rb
|
|
281
296
|
- lib/mongoid/errors/invalid_around_callback.rb
|
|
282
297
|
- lib/mongoid/errors/invalid_async_query_executor.rb
|
|
283
298
|
- lib/mongoid/errors/invalid_auto_encryption_configuration.rb
|
|
@@ -321,6 +336,7 @@ files:
|
|
|
321
336
|
- lib/mongoid/errors/no_client_hosts.rb
|
|
322
337
|
- lib/mongoid/errors/no_clients_config.rb
|
|
323
338
|
- lib/mongoid/errors/no_default_client.rb
|
|
339
|
+
- lib/mongoid/errors/no_encryption_schema.rb
|
|
324
340
|
- lib/mongoid/errors/no_environment.rb
|
|
325
341
|
- lib/mongoid/errors/no_map_reduce_output.rb
|
|
326
342
|
- lib/mongoid/errors/no_metadata.rb
|
|
@@ -368,6 +384,7 @@ files:
|
|
|
368
384
|
- lib/mongoid/extensions/time_with_zone.rb
|
|
369
385
|
- lib/mongoid/extensions/true_class.rb
|
|
370
386
|
- lib/mongoid/factory.rb
|
|
387
|
+
- lib/mongoid/field_readable.rb
|
|
371
388
|
- lib/mongoid/fields.rb
|
|
372
389
|
- lib/mongoid/fields/encrypted.rb
|
|
373
390
|
- lib/mongoid/fields/foreign_key.rb
|
|
@@ -415,6 +432,7 @@ files:
|
|
|
415
432
|
- lib/mongoid/matcher/not.rb
|
|
416
433
|
- lib/mongoid/matcher/or.rb
|
|
417
434
|
- lib/mongoid/matcher/regex.rb
|
|
435
|
+
- lib/mongoid/matcher/regexp_budget.rb
|
|
418
436
|
- lib/mongoid/matcher/size.rb
|
|
419
437
|
- lib/mongoid/matcher/type.rb
|
|
420
438
|
- lib/mongoid/model_resolver.rb
|
|
@@ -584,9 +602,11 @@ files:
|
|
|
584
602
|
- spec/integration/matcher_operator_data/type_timestamp.yml
|
|
585
603
|
- spec/integration/matcher_operator_data/type_undefined.yml
|
|
586
604
|
- spec/integration/matcher_operator_spec.rb
|
|
605
|
+
- spec/integration/matcher_regexp_timeout_spec.rb
|
|
587
606
|
- spec/integration/matcher_spec.rb
|
|
588
607
|
- spec/integration/persistence/collection_options_spec.rb
|
|
589
608
|
- spec/integration/persistence/range_field_spec.rb
|
|
609
|
+
- spec/integration/query_operator_guard_spec.rb
|
|
590
610
|
- spec/integration/server_query_spec.rb
|
|
591
611
|
- spec/integration/shardable_spec.rb
|
|
592
612
|
- spec/integration/stringified_symbol_field_spec.rb
|
|
@@ -750,6 +770,7 @@ files:
|
|
|
750
770
|
- spec/mongoid/document_persistence_context_spec.rb
|
|
751
771
|
- spec/mongoid/document_query_spec.rb
|
|
752
772
|
- spec/mongoid/document_spec.rb
|
|
773
|
+
- spec/mongoid/encryptable_spec.rb
|
|
753
774
|
- spec/mongoid/equality_spec.rb
|
|
754
775
|
- spec/mongoid/errors/ambiguous_relationship_spec.rb
|
|
755
776
|
- spec/mongoid/errors/attribute_not_loaded_spec.rb
|
|
@@ -837,6 +858,7 @@ files:
|
|
|
837
858
|
- spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
|
|
838
859
|
- spec/mongoid/matcher/extract_attribute_data/traversal.yml
|
|
839
860
|
- spec/mongoid/matcher/extract_attribute_spec.rb
|
|
861
|
+
- spec/mongoid/matcher/regexp_budget_spec.rb
|
|
840
862
|
- spec/mongoid/model_resolver_spec.rb
|
|
841
863
|
- spec/mongoid/mongoizable_spec.rb
|
|
842
864
|
- spec/mongoid/monkey_patches_spec.rb
|
|
@@ -1231,7 +1253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1231
1253
|
- !ruby/object:Gem::Version
|
|
1232
1254
|
version: 1.3.6
|
|
1233
1255
|
requirements: []
|
|
1234
|
-
rubygems_version: 4.0.
|
|
1256
|
+
rubygems_version: 4.0.21
|
|
1235
1257
|
specification_version: 4
|
|
1236
1258
|
summary: Elegant Persistence in Ruby for MongoDB.
|
|
1237
1259
|
test_files:
|
|
@@ -1332,9 +1354,11 @@ test_files:
|
|
|
1332
1354
|
- spec/integration/matcher_operator_data/type_timestamp.yml
|
|
1333
1355
|
- spec/integration/matcher_operator_data/type_undefined.yml
|
|
1334
1356
|
- spec/integration/matcher_operator_spec.rb
|
|
1357
|
+
- spec/integration/matcher_regexp_timeout_spec.rb
|
|
1335
1358
|
- spec/integration/matcher_spec.rb
|
|
1336
1359
|
- spec/integration/persistence/collection_options_spec.rb
|
|
1337
1360
|
- spec/integration/persistence/range_field_spec.rb
|
|
1361
|
+
- spec/integration/query_operator_guard_spec.rb
|
|
1338
1362
|
- spec/integration/server_query_spec.rb
|
|
1339
1363
|
- spec/integration/shardable_spec.rb
|
|
1340
1364
|
- spec/integration/stringified_symbol_field_spec.rb
|
|
@@ -1498,6 +1522,7 @@ test_files:
|
|
|
1498
1522
|
- spec/mongoid/document_persistence_context_spec.rb
|
|
1499
1523
|
- spec/mongoid/document_query_spec.rb
|
|
1500
1524
|
- spec/mongoid/document_spec.rb
|
|
1525
|
+
- spec/mongoid/encryptable_spec.rb
|
|
1501
1526
|
- spec/mongoid/equality_spec.rb
|
|
1502
1527
|
- spec/mongoid/errors/ambiguous_relationship_spec.rb
|
|
1503
1528
|
- spec/mongoid/errors/attribute_not_loaded_spec.rb
|
|
@@ -1585,6 +1610,7 @@ test_files:
|
|
|
1585
1610
|
- spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
|
|
1586
1611
|
- spec/mongoid/matcher/extract_attribute_data/traversal.yml
|
|
1587
1612
|
- spec/mongoid/matcher/extract_attribute_spec.rb
|
|
1613
|
+
- spec/mongoid/matcher/regexp_budget_spec.rb
|
|
1588
1614
|
- spec/mongoid/model_resolver_spec.rb
|
|
1589
1615
|
- spec/mongoid/mongoizable_spec.rb
|
|
1590
1616
|
- spec/mongoid/monkey_patches_spec.rb
|