Skip to content

MONGOID-5739 Support BSON 5 #2848

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

Merged
merged 6 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions mongo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,5 @@ Gem::Specification.new do |s|

s.required_ruby_version = ">= 2.5"

# For testing driver against bson master we need to depend on bson < 6.0.0
# but in release version we want to depend on bson < 5.0.0.
if %w(1 yes true).include?(ENV['MONGO_RUBY_DRIVER_BSON_MASTER'])
s.add_dependency 'bson', '>=4.13.0', '<6.0.0'
else
s.add_dependency 'bson', '>=4.14.1', '<5.0.0'
end
s.add_dependency 'bson', '>=4.14.1', '<6.0.0'
end
12 changes: 10 additions & 2 deletions spec/integration/client_side_encryption/corpus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@
key_vault_collection.insert_one(kmip_data_key)
end

# This method compensates for an API change between BSON 4 and
# BSON 5.
def normalize_cse_value(a)
case a
when BSON::Decimal128 then a.to_d
else a
end
end

shared_context 'with jsonSchema collection validator' do
let(:local_schema_map) { nil }

Expand Down Expand Up @@ -228,12 +237,11 @@
.find(_id: corpus_encrypted_id)
.first


corpus_encrypted_actual.each do |key, value|
# If it was deterministically encrypted, test the encrypted values
# for equality.
if value['algo'] == 'det'
expect(value['value']).to eq(corpus_encrypted_expected[key]['value'])
expect(normalize_cse_value(value['value'])).to eq(normalize_cse_value(corpus_encrypted_expected[key]['value']))
else
# If the document was randomly encrypted, the two encrypted values
# will not be equal. Ensure that they are equal when decrypted.
Expand Down
2 changes: 1 addition & 1 deletion spec/shared