Skip to content

Commit 0c65ebf

Browse files
authored
MONGOID-5739 Support BSON 5 (#2848)
* MONGOID-5739 support BSON 5 * point at my personal branch to test this * normalize values before comparing * switch back to the official spec/shared repo * actually bump spec/shared (why are submodules so impossible?) * use pessimistic versioning
1 parent d332cd9 commit 0c65ebf

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

mongo.gemspec

+1-7
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,5 @@ Gem::Specification.new do |s|
4141

4242
s.required_ruby_version = ">= 2.5"
4343

44-
# For testing driver against bson master we need to depend on bson < 6.0.0
45-
# but in release version we want to depend on bson < 5.0.0.
46-
if %w(1 yes true).include?(ENV['MONGO_RUBY_DRIVER_BSON_MASTER'])
47-
s.add_dependency 'bson', '>=4.13.0', '<6.0.0'
48-
else
49-
s.add_dependency 'bson', '>=4.14.1', '<5.0.0'
50-
end
44+
s.add_dependency 'bson', '>=4.14.1', '<6.0.0'
5145
end

spec/integration/client_side_encryption/corpus_spec.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,15 @@
188188
key_vault_collection.insert_one(kmip_data_key)
189189
end
190190

191+
# This method compensates for an API change between BSON 4 and
192+
# BSON 5.
193+
def normalize_cse_value(a)
194+
case a
195+
when BSON::Decimal128 then a.to_d
196+
else a
197+
end
198+
end
199+
191200
shared_context 'with jsonSchema collection validator' do
192201
let(:local_schema_map) { nil }
193202

@@ -228,12 +237,11 @@
228237
.find(_id: corpus_encrypted_id)
229238
.first
230239

231-
232240
corpus_encrypted_actual.each do |key, value|
233241
# If it was deterministically encrypted, test the encrypted values
234242
# for equality.
235243
if value['algo'] == 'det'
236-
expect(value['value']).to eq(corpus_encrypted_expected[key]['value'])
244+
expect(normalize_cse_value(value['value'])).to eq(normalize_cse_value(corpus_encrypted_expected[key]['value']))
237245
else
238246
# If the document was randomly encrypted, the two encrypted values
239247
# will not be equal. Ensure that they are equal when decrypted.

0 commit comments

Comments
 (0)