bson 4.14.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +4 -4
- data/Rakefile +5 -0
- data/ext/bson/bson-native.h +12 -4
- data/ext/bson/extconf.rb +8 -3
- data/ext/bson/init.c +11 -11
- data/ext/bson/read.c +21 -6
- data/ext/bson/util.c +168 -16
- data/ext/bson/write.c +30 -39
- data/lib/bson/active_support.rb +1 -0
- data/lib/bson/array.rb +57 -31
- data/lib/bson/big_decimal.rb +16 -6
- data/lib/bson/binary.rb +255 -128
- data/lib/bson/boolean.rb +1 -0
- data/lib/bson/code.rb +9 -11
- data/lib/bson/code_with_scope.rb +8 -10
- data/lib/bson/config.rb +1 -27
- data/lib/bson/date.rb +2 -1
- data/lib/bson/date_time.rb +2 -1
- data/lib/bson/db_pointer.rb +11 -12
- data/lib/bson/dbref.rb +11 -9
- data/lib/bson/decimal128/builder.rb +9 -8
- data/lib/bson/decimal128.rb +33 -109
- data/lib/bson/document.rb +1 -0
- data/lib/bson/environment.rb +1 -0
- data/lib/bson/error/bson_decode_error.rb +11 -0
- data/lib/bson/error/ext_json_parse_error.rb +11 -0
- data/lib/bson/error/illegal_key.rb +23 -0
- data/lib/bson/error/invalid_binary_type.rb +37 -0
- data/lib/bson/error/invalid_dbref_argument.rb +12 -0
- data/lib/bson/error/invalid_decimal128_argument.rb +25 -0
- data/lib/bson/error/invalid_decimal128_range.rb +27 -0
- data/lib/bson/error/invalid_decimal128_string.rb +26 -0
- data/lib/bson/error/invalid_key.rb +24 -0
- data/lib/bson/error/invalid_object_id.rb +11 -0
- data/lib/bson/error/invalid_regexp_pattern.rb +13 -0
- data/lib/bson/error/unrepresentable_precision.rb +19 -0
- data/lib/bson/error/unserializable_class.rb +13 -0
- data/lib/bson/error/unsupported_binary_subtype.rb +12 -0
- data/lib/bson/error/unsupported_type.rb +11 -0
- data/lib/bson/error.rb +16 -28
- data/lib/bson/ext_json.rb +1 -0
- data/lib/bson/false_class.rb +2 -1
- data/lib/bson/float.rb +2 -1
- data/lib/bson/hash.rb +127 -72
- data/lib/bson/int32.rb +16 -4
- data/lib/bson/int64.rb +16 -4
- data/lib/bson/integer.rb +3 -4
- data/lib/bson/json.rb +1 -0
- data/lib/bson/max_key.rb +7 -9
- data/lib/bson/min_key.rb +7 -9
- data/lib/bson/nil_class.rb +1 -0
- data/lib/bson/object.rb +5 -25
- data/lib/bson/object_id.rb +75 -121
- data/lib/bson/open_struct.rb +3 -2
- data/lib/bson/regexp.rb +35 -64
- data/lib/bson/registry.rb +2 -6
- data/lib/bson/specialized.rb +2 -1
- data/lib/bson/string.rb +4 -27
- data/lib/bson/symbol.rb +22 -19
- data/lib/bson/time.rb +2 -1
- data/lib/bson/time_with_zone.rb +13 -1
- data/lib/bson/timestamp.rb +2 -1
- data/lib/bson/true_class.rb +2 -1
- data/lib/bson/undefined.rb +14 -0
- data/lib/bson/version.rb +2 -1
- data/lib/bson.rb +3 -2
- data/spec/bson/array_spec.rb +19 -60
- data/spec/bson/big_decimal_spec.rb +16 -4
- data/spec/bson/binary_spec.rb +83 -74
- data/spec/bson/binary_uuid_spec.rb +1 -0
- data/spec/bson/boolean_spec.rb +1 -0
- data/spec/bson/byte_buffer_read_spec.rb +1 -0
- data/spec/bson/byte_buffer_spec.rb +1 -0
- data/spec/bson/byte_buffer_write_spec.rb +1 -0
- data/spec/bson/code_spec.rb +5 -3
- data/spec/bson/code_with_scope_spec.rb +5 -3
- data/spec/bson/config_spec.rb +1 -35
- data/spec/bson/date_spec.rb +1 -0
- data/spec/bson/date_time_spec.rb +1 -0
- data/spec/bson/dbref_legacy_spec.rb +20 -3
- data/spec/bson/dbref_spec.rb +9 -9
- data/spec/bson/decimal128_spec.rb +249 -14
- data/spec/bson/document_as_spec.rb +1 -0
- data/spec/bson/document_spec.rb +1 -1
- data/spec/bson/ext_json_parse_spec.rb +1 -0
- data/spec/bson/false_class_spec.rb +8 -0
- data/spec/bson/float_spec.rb +8 -3
- data/spec/bson/hash_as_spec.rb +1 -0
- data/spec/bson/hash_spec.rb +87 -75
- data/spec/bson/int32_spec.rb +21 -6
- data/spec/bson/int64_spec.rb +21 -6
- data/spec/bson/integer_spec.rb +45 -13
- data/spec/bson/json_spec.rb +1 -0
- data/spec/bson/max_key_spec.rb +5 -3
- data/spec/bson/min_key_spec.rb +5 -3
- data/spec/bson/nil_class_spec.rb +1 -0
- data/spec/bson/object_id_spec.rb +43 -4
- data/spec/bson/object_spec.rb +2 -1
- data/spec/bson/open_struct_spec.rb +14 -71
- data/spec/bson/raw_spec.rb +9 -15
- data/spec/bson/regexp_spec.rb +4 -3
- data/spec/bson/registry_spec.rb +2 -1
- data/spec/bson/string_spec.rb +13 -38
- data/spec/bson/symbol_raw_spec.rb +25 -0
- data/spec/bson/symbol_spec.rb +15 -18
- data/spec/bson/time_spec.rb +1 -0
- data/spec/bson/time_with_zone_spec.rb +1 -0
- data/spec/bson/timestamp_spec.rb +1 -0
- data/spec/bson/true_class_spec.rb +8 -0
- data/spec/bson/undefined_spec.rb +27 -0
- data/spec/bson_spec.rb +1 -0
- data/spec/runners/common_driver.rb +6 -5
- data/spec/runners/corpus.rb +6 -0
- data/spec/runners/corpus_legacy.rb +1 -0
- data/spec/shared/lib/mrss/constraints.rb +8 -16
- data/spec/shared/lib/mrss/docker_runner.rb +30 -3
- data/spec/shared/lib/mrss/eg_config_utils.rb +51 -0
- data/spec/shared/lib/mrss/event_subscriber.rb +15 -5
- data/spec/shared/lib/mrss/lite_constraints.rb +48 -1
- data/spec/shared/lib/mrss/server_version_registry.rb +16 -23
- data/spec/shared/lib/mrss/session_registry.rb +69 -0
- data/spec/shared/lib/mrss/session_registry_legacy.rb +60 -0
- data/spec/shared/lib/mrss/utils.rb +28 -6
- data/spec/shared/share/Dockerfile.erb +68 -85
- data/spec/shared/shlib/config.sh +27 -0
- data/spec/shared/shlib/server.sh +73 -24
- data/spec/shared/shlib/set_env.sh +39 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/spec_tests/common_driver_spec.rb +9 -4
- data/spec/spec_tests/corpus_legacy_spec.rb +1 -0
- data/spec/spec_tests/corpus_spec.rb +13 -3
- data/spec/spec_tests/data/corpus/binary.json +5 -0
- data/spec/spec_tests/data/corpus/code.json +13 -13
- data/spec/spec_tests/data/corpus/decimal128-4.json +48 -0
- data/spec/spec_tests/data/corpus/decimal128-6.json +12 -0
- data/spec/spec_tests/data/corpus/decimal128-7.json +4 -0
- data/spec/spec_tests/data/corpus/document.json +20 -0
- data/spec/spec_tests/data/corpus/symbol.json +7 -7
- data/spec/spec_tests/data/corpus/top.json +18 -3
- data/spec/support/shared_examples.rb +28 -5
- data/spec/support/spec_config.rb +1 -0
- data/spec/support/utils.rb +49 -1
- data.tar.gz.sig +0 -0
- metadata +167 -143
- metadata.gz.sig +0 -0
data/spec/shared/shlib/server.sh
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# This file contains functions pertaining to downloading, starting and
|
2
2
|
# configuring a MongoDB server.
|
3
3
|
|
4
|
+
# Note that mlaunch is executed with (and therefore installed with) Python 2.
|
5
|
+
# The reason for this is that in the past, some of the distros we tested on
|
6
|
+
# had an ancient version of Python 3 that was unusable (e.g. it couldn't
|
7
|
+
# install anything from PyPI due to outdated TLS/SSL implementation).
|
8
|
+
# It is likely that all of the current distros we use have a recent enough
|
9
|
+
# and working Python 3 implementation, such that we could use Python 3 for
|
10
|
+
# everything.
|
11
|
+
#
|
12
|
+
# Note that some distros (e.g. ubuntu2004) do not contain a `python' binary
|
13
|
+
# at all, thus python2 or python3 must be explicitly specified depending on
|
14
|
+
# the desired version.
|
15
|
+
|
4
16
|
set_fcv() {
|
5
17
|
if test -n "$FCV"; then
|
6
18
|
mongo --eval 'assert.commandWorked(db.adminCommand( { setFeatureCompatibilityVersion: "'"$FCV"'" } ));' "$MONGODB_URI"
|
@@ -34,44 +46,65 @@ prepare_server() {
|
|
34
46
|
if test "$MONGODB_VERSION" = latest; then
|
35
47
|
# Test on the most recent published 4.3 release.
|
36
48
|
# https://jira.mongodb.org/browse/RUBY-1724
|
37
|
-
|
38
|
-
|
49
|
+
|
50
|
+
. $PROJECT_DIRECTORY/.mod/drivers-evergreen-tools/.evergreen/download-mongodb.sh
|
51
|
+
|
52
|
+
get_distro
|
53
|
+
get_mongodb_download_url_for "$DISTRO" "latest"
|
54
|
+
prepare_server_from_url $MONGODB_DOWNLOAD_URL
|
39
55
|
else
|
40
56
|
download_version="$MONGODB_VERSION"
|
57
|
+
url=`$(dirname $0)/get-mongodb-download-url $download_version $arch`
|
58
|
+
prepare_server_from_url $url
|
41
59
|
fi
|
42
60
|
|
43
|
-
url=`$(dirname $0)/get-mongodb-download-url $download_version $arch`
|
44
|
-
|
45
|
-
prepare_server_from_url $url
|
46
61
|
}
|
47
62
|
|
48
63
|
prepare_server_from_url() {
|
49
64
|
url=$1
|
50
65
|
|
51
|
-
|
66
|
+
dirname=`basename $url |sed -e s/.tgz//`
|
67
|
+
mongodb_dir="$MONGO_ORCHESTRATION_HOME"/mdb/"$dirname"
|
52
68
|
mkdir -p "$mongodb_dir"
|
53
|
-
curl --retry 3 $url |tar xz -C "$mongodb_dir" -f -
|
54
|
-
BINDIR="$mongodb_dir"
|
69
|
+
curl --retry 3 $url | tar xz -C "$mongodb_dir" --strip-components 1 -f -
|
70
|
+
BINDIR="$mongodb_dir"/bin
|
55
71
|
export PATH="$BINDIR":$PATH
|
56
72
|
}
|
57
73
|
|
58
|
-
|
59
|
-
|
60
|
-
if !
|
74
|
+
install_mlaunch_venv() {
|
75
|
+
python3 -V || true
|
76
|
+
if ! python3 -m venv -h >/dev/null; then
|
61
77
|
# Current virtualenv fails with
|
62
78
|
# https://github.com/pypa/virtualenv/issues/1630
|
63
|
-
|
79
|
+
python3 -m pip install venv --user
|
80
|
+
fi
|
81
|
+
if ! python3 -m ensurepip -h > /dev/null; then
|
82
|
+
# Debian11/Ubuntu2204 have venv installed, but it is nonfunctional unless
|
83
|
+
# the python3-venv package is also installed (it lacks the ensurepip
|
84
|
+
# module).
|
85
|
+
sudo apt-get install --yes python3-venv
|
64
86
|
fi
|
65
87
|
if test "$USE_SYSTEM_PYTHON_PACKAGES" = 1 &&
|
66
|
-
|
88
|
+
python3 -m pip list |grep mtools
|
67
89
|
then
|
68
90
|
# Use the existing mtools-legacy
|
69
91
|
:
|
70
92
|
else
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
93
|
+
# Spawn a virtual environment, but only if one is not already
|
94
|
+
# active...
|
95
|
+
if test -z "$VIRTUAL_ENV"; then
|
96
|
+
venvpath="$MONGO_ORCHESTRATION_HOME"/venv
|
97
|
+
python3 -m venv $venvpath
|
98
|
+
. $venvpath/bin/activate
|
99
|
+
fi
|
100
|
+
|
101
|
+
# [mlaunch] does not work:
|
102
|
+
# https://github.com/rueckstiess/mtools/issues/856
|
103
|
+
# dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
|
104
|
+
#pip install 'mtools==1.7' 'pymongo==4.1' python-dateutil psutil
|
105
|
+
|
106
|
+
# dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
|
107
|
+
pip install 'mtools-legacy[mlaunch]' 'pymongo<4' python-dateutil
|
75
108
|
fi
|
76
109
|
}
|
77
110
|
|
@@ -84,7 +117,8 @@ install_mlaunch_pip() {
|
|
84
117
|
python -V || true
|
85
118
|
python3 -V || true
|
86
119
|
pythonpath="$MONGO_ORCHESTRATION_HOME"/python
|
87
|
-
|
120
|
+
# dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
|
121
|
+
pip install -t "$pythonpath" 'mtools-legacy[mlaunch]' 'pymongo<4' python-dateutil
|
88
122
|
export PATH="$pythonpath/bin":$PATH
|
89
123
|
export PYTHONPATH="$pythonpath"
|
90
124
|
}
|
@@ -108,7 +142,8 @@ install_mlaunch_git() {
|
|
108
142
|
virtualenv -p python3 $venvpath
|
109
143
|
. $venvpath/bin/activate
|
110
144
|
|
111
|
-
|
145
|
+
# dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
|
146
|
+
pip3 install psutil pymongo python-dateutil
|
112
147
|
|
113
148
|
git clone $repo mlaunch
|
114
149
|
cd mlaunch
|
@@ -123,16 +158,30 @@ install_mlaunch_git() {
|
|
123
158
|
virtualenv $venvpath
|
124
159
|
. $venvpath/bin/activate
|
125
160
|
|
126
|
-
|
161
|
+
# dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
|
162
|
+
pip install psutil pymongo python-dateutil
|
127
163
|
|
128
164
|
git clone $repo mlaunch
|
129
165
|
(cd mlaunch &&
|
130
166
|
git checkout origin/$branch &&
|
131
|
-
|
167
|
+
python2 setup.py install
|
132
168
|
)
|
133
169
|
fi
|
134
170
|
}
|
135
171
|
|
172
|
+
install_cmake() {
|
173
|
+
if ! command -v cmake &> /dev/null; then
|
174
|
+
if ! command -v apt-get &> /dev/null; then
|
175
|
+
# no apt-get; assume RHEL
|
176
|
+
sudo yum -y install cmake libarchive
|
177
|
+
else
|
178
|
+
sudo apt-get install --yes cmake
|
179
|
+
fi
|
180
|
+
else
|
181
|
+
echo 'cmake is present'
|
182
|
+
fi
|
183
|
+
}
|
184
|
+
|
136
185
|
# This function sets followong global variables:
|
137
186
|
# server_cert_path
|
138
187
|
# server_ca_path
|
@@ -148,7 +197,7 @@ calculate_server_args() {
|
|
148
197
|
fi
|
149
198
|
|
150
199
|
if test $mongo_version = latest; then
|
151
|
-
mongo_version=
|
200
|
+
mongo_version=70
|
152
201
|
fi
|
153
202
|
|
154
203
|
local args="--setParameter enableTestCommands=1"
|
@@ -309,7 +358,7 @@ launch_ocsp_mock() {
|
|
309
358
|
|
310
359
|
launch_server() {
|
311
360
|
local dbdir="$1"
|
312
|
-
|
361
|
+
python3 -m mtools.mlaunch.mlaunch --dir "$dbdir" --binarypath "$BINDIR" $SERVER_ARGS
|
313
362
|
|
314
363
|
if test "$TOPOLOGY" = sharded-cluster && test $MONGODB_VERSION = 3.6; then
|
315
364
|
# On 3.6 server the sessions collection is not immediately available,
|
@@ -345,7 +394,7 @@ launch_server() {
|
|
345
394
|
port="${BASH_REMATCH[1]}"
|
346
395
|
mongoses+=("${base_url}:${port}")
|
347
396
|
fi
|
348
|
-
done < <(
|
397
|
+
done < <(python2 -m mtools.mlaunch.mlaunch list --dir "$dbdir" --binarypath "$BINDIR")
|
349
398
|
|
350
399
|
if [ -n "$config_server" ]; then
|
351
400
|
${mongo_command} "$config_server" --eval 'db.adminCommand("refreshLogicalSessionCacheNow")'
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
# When changing, also update the hash in share/Dockerfile.
|
2
|
+
TOOLCHAIN_VERSION=e8c60866f54bed7e336a37df3a97d6ae1b971b7d
|
2
3
|
|
3
4
|
set_env_java() {
|
4
5
|
ls -l /opt || true
|
@@ -44,6 +45,43 @@ set_env_java() {
|
|
44
45
|
fi
|
45
46
|
}
|
46
47
|
|
48
|
+
set_env_python() {
|
49
|
+
if test "$DOCKER_PRELOAD" != 1; then
|
50
|
+
if test -n "$DOCKER"; then
|
51
|
+
# If we are running in Docker and not preloading, we need to fetch the
|
52
|
+
# Python binary.
|
53
|
+
curl -fL --retry 3 https://github.com/p-mongodb/deps/raw/main/"$arch"-python37.tar.xz | \
|
54
|
+
tar xfJ - -C /opt
|
55
|
+
fi
|
56
|
+
|
57
|
+
if test -d /opt/python/3.7/bin; then
|
58
|
+
# Most Evergreen configurations.
|
59
|
+
export PATH=/opt/python/3.7/bin:$PATH
|
60
|
+
elif test -d /opt/python37/bin; then
|
61
|
+
# Configurations that use Docker in Evergreen - these don't preload.
|
62
|
+
export PATH=/opt/python37/bin:$PATH
|
63
|
+
fi
|
64
|
+
|
65
|
+
python3 -V
|
66
|
+
fi
|
67
|
+
}
|
68
|
+
|
69
|
+
set_env_node() {
|
70
|
+
if test "$DOCKER_PRELOAD" != 1; then
|
71
|
+
dir=`ls -d /opt/nodejs/node-v12* |head -1`
|
72
|
+
if test -z "$dir"; then
|
73
|
+
echo "Node 12 missing" 1>&2
|
74
|
+
exit 2
|
75
|
+
fi
|
76
|
+
export PATH="$dir/bin:$PATH"
|
77
|
+
elif test -d /opt/node/bin; then
|
78
|
+
# Node from toolchain in Evergreen
|
79
|
+
export PATH=/opt/node/bin:$PATH
|
80
|
+
fi
|
81
|
+
|
82
|
+
node -v
|
83
|
+
}
|
84
|
+
|
47
85
|
set_env_ruby() {
|
48
86
|
if test -z "$RVM_RUBY"; then
|
49
87
|
echo "Empty RVM_RUBY, aborting"
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# rubocop:todo all
|
1
2
|
require 'spec_helper'
|
2
3
|
require 'runners/common_driver'
|
3
4
|
|
@@ -25,8 +26,12 @@ describe 'Driver common bson tests' do
|
|
25
26
|
expect(test.from_json_string).to eq(test.object)
|
26
27
|
end
|
27
28
|
|
29
|
+
it 'serializes to a string', if: test.to_ext_json? do
|
30
|
+
expect(test.document_as_extended_json).to eq(test.ext_json)
|
31
|
+
end
|
32
|
+
|
28
33
|
it 'creates the correct extended json document from the decoded object', if: test.to_ext_json? do
|
29
|
-
expect(test.
|
34
|
+
expect(test.document_as_extended_json).to eq(test.ext_json)
|
30
35
|
end
|
31
36
|
|
32
37
|
it 'parses the string value to the same value as the decoded document', if: test.from_string? do
|
@@ -63,9 +68,9 @@ describe 'Driver common bson tests' do
|
|
63
68
|
|
64
69
|
let(:valid_errors) do
|
65
70
|
[
|
66
|
-
BSON::
|
67
|
-
BSON::
|
68
|
-
BSON::
|
71
|
+
BSON::Error::InvalidDecimal128String,
|
72
|
+
BSON::Error::InvalidDecimal128Range,
|
73
|
+
BSON::Error::UnrepresentablePrecision,
|
69
74
|
]
|
70
75
|
end
|
71
76
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# rubocop:todo all
|
1
2
|
require 'spec_helper'
|
2
3
|
require 'runners/corpus'
|
3
4
|
|
@@ -105,8 +106,17 @@ describe 'BSON Corpus spec tests' do
|
|
105
106
|
|
106
107
|
context("parse error: #{test.description}") do
|
107
108
|
|
108
|
-
|
109
|
-
|
109
|
+
# As per:
|
110
|
+
# https://github.com/mongodb/specifications/blob/e7ee829329400786e01279b4f37d4e440d1e9cfa/source/bson-corpus/bson-corpus.rst#decimal128-type-0x13
|
111
|
+
#
|
112
|
+
# Values under test must be parsed in a type-specific manner.
|
113
|
+
let(:parsed_value) do
|
114
|
+
case spec.bson_type
|
115
|
+
when BSON::Decimal128::BSON_TYPE
|
116
|
+
BSON::Decimal128.new(test.string)
|
117
|
+
else
|
118
|
+
BSON::ExtJSON.parse(test.string, mode: :bson)
|
119
|
+
end
|
110
120
|
end
|
111
121
|
|
112
122
|
# Until bson-ruby gets an exception hierarchy, we can only rescue
|
@@ -114,7 +124,7 @@ describe 'BSON Corpus spec tests' do
|
|
114
124
|
# https://jira.mongodb.org/browse/RUBY-1806
|
115
125
|
it 'raises an exception' do
|
116
126
|
expect do
|
117
|
-
|
127
|
+
parsed_value
|
118
128
|
end.to raise_error(Exception)
|
119
129
|
end
|
120
130
|
end
|
@@ -55,6 +55,11 @@
|
|
55
55
|
"canonical_bson": "1D000000057800100000000773FFD26444B34C6990E8E7D1DFC035D400",
|
56
56
|
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"07\"}}}"
|
57
57
|
},
|
58
|
+
{
|
59
|
+
"description": "subtype 0x08",
|
60
|
+
"canonical_bson": "1D000000057800100000000873FFD26444B34C6990E8E7D1DFC035D400",
|
61
|
+
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"08\"}}}"
|
62
|
+
},
|
58
63
|
{
|
59
64
|
"description": "subtype 0x80",
|
60
65
|
"canonical_bson": "0F0000000578000200000080FFFF00",
|
@@ -20,48 +20,48 @@
|
|
20
20
|
},
|
21
21
|
{
|
22
22
|
"description": "two-byte UTF-8 (\u00e9)",
|
23
|
-
"canonical_bson": "
|
24
|
-
"canonical_extjson": "{\"a\" : \"\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\"}"
|
23
|
+
"canonical_bson": "190000000D61000D000000C3A9C3A9C3A9C3A9C3A9C3A90000",
|
24
|
+
"canonical_extjson": "{\"a\" : {\"$code\" : \"\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\"}}"
|
25
25
|
},
|
26
26
|
{
|
27
27
|
"description": "three-byte UTF-8 (\u2606)",
|
28
|
-
"canonical_bson": "
|
29
|
-
"canonical_extjson": "{\"a\" : \"\\u2606\\u2606\\u2606\\u2606\"}"
|
28
|
+
"canonical_bson": "190000000D61000D000000E29886E29886E29886E298860000",
|
29
|
+
"canonical_extjson": "{\"a\" : {\"$code\" : \"\\u2606\\u2606\\u2606\\u2606\"}}"
|
30
30
|
},
|
31
31
|
{
|
32
32
|
"description": "Embedded nulls",
|
33
|
-
"canonical_bson": "
|
34
|
-
"canonical_extjson": "{\"a\" : \"ab\\u0000bab\\u0000babab\"}"
|
33
|
+
"canonical_bson": "190000000D61000D0000006162006261620062616261620000",
|
34
|
+
"canonical_extjson": "{\"a\" : {\"$code\" : \"ab\\u0000bab\\u0000babab\"}}"
|
35
35
|
}
|
36
36
|
],
|
37
37
|
"decodeErrors": [
|
38
38
|
{
|
39
39
|
"description": "bad code string length: 0 (but no 0x00 either)",
|
40
|
-
"bson": "
|
40
|
+
"bson": "0C0000000D61000000000000"
|
41
41
|
},
|
42
42
|
{
|
43
43
|
"description": "bad code string length: -1",
|
44
|
-
"bson": "
|
44
|
+
"bson": "0C0000000D6100FFFFFFFF00"
|
45
45
|
},
|
46
46
|
{
|
47
47
|
"description": "bad code string length: eats terminator",
|
48
|
-
"bson": "
|
48
|
+
"bson": "100000000D6100050000006200620000"
|
49
49
|
},
|
50
50
|
{
|
51
51
|
"description": "bad code string length: longer than rest of document",
|
52
|
-
"bson": "
|
52
|
+
"bson": "120000000D00FFFFFF00666F6F6261720000"
|
53
53
|
},
|
54
54
|
{
|
55
55
|
"description": "code string is not null-terminated",
|
56
|
-
"bson": "
|
56
|
+
"bson": "100000000D610004000000616263FF00"
|
57
57
|
},
|
58
58
|
{
|
59
59
|
"description": "empty code string, but extra null",
|
60
|
-
"bson": "
|
60
|
+
"bson": "0E0000000D610001000000000000"
|
61
61
|
},
|
62
62
|
{
|
63
63
|
"description": "invalid UTF-8",
|
64
|
-
"bson": "
|
64
|
+
"bson": "0E0000000D610002000000E90000"
|
65
65
|
}
|
66
66
|
]
|
67
67
|
}
|
@@ -112,6 +112,54 @@
|
|
112
112
|
{
|
113
113
|
"description": "[basx563] Near-specials (Conversion_syntax)",
|
114
114
|
"string": "NaNs"
|
115
|
+
},
|
116
|
+
{
|
117
|
+
"description": "[dqbas939] overflow results at different rounding modes (Overflow & Inexact & Rounded)",
|
118
|
+
"string": "-7e10000"
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"description": "[dqbsr534] negatives (Rounded & Inexact)",
|
122
|
+
"string": "-1.11111111111111111111111111111234650"
|
123
|
+
},
|
124
|
+
{
|
125
|
+
"description": "[dqbsr535] negatives (Rounded & Inexact)",
|
126
|
+
"string": "-1.11111111111111111111111111111234551"
|
127
|
+
},
|
128
|
+
{
|
129
|
+
"description": "[dqbsr533] negatives (Rounded & Inexact)",
|
130
|
+
"string": "-1.11111111111111111111111111111234550"
|
131
|
+
},
|
132
|
+
{
|
133
|
+
"description": "[dqbsr532] negatives (Rounded & Inexact)",
|
134
|
+
"string": "-1.11111111111111111111111111111234549"
|
135
|
+
},
|
136
|
+
{
|
137
|
+
"description": "[dqbsr432] check rounding modes heeded (Rounded & Inexact)",
|
138
|
+
"string": "1.11111111111111111111111111111234549"
|
139
|
+
},
|
140
|
+
{
|
141
|
+
"description": "[dqbsr433] check rounding modes heeded (Rounded & Inexact)",
|
142
|
+
"string": "1.11111111111111111111111111111234550"
|
143
|
+
},
|
144
|
+
{
|
145
|
+
"description": "[dqbsr435] check rounding modes heeded (Rounded & Inexact)",
|
146
|
+
"string": "1.11111111111111111111111111111234551"
|
147
|
+
},
|
148
|
+
{
|
149
|
+
"description": "[dqbsr434] check rounding modes heeded (Rounded & Inexact)",
|
150
|
+
"string": "1.11111111111111111111111111111234650"
|
151
|
+
},
|
152
|
+
{
|
153
|
+
"description": "[dqbas938] overflow results at different rounding modes (Overflow & Inexact & Rounded)",
|
154
|
+
"string": "7e10000"
|
155
|
+
},
|
156
|
+
{
|
157
|
+
"description": "Inexact rounding#1",
|
158
|
+
"string": "100000000000000000000000000000000000000000000000000000000001"
|
159
|
+
},
|
160
|
+
{
|
161
|
+
"description": "Inexact rounding#2",
|
162
|
+
"string": "1E-6177"
|
115
163
|
}
|
116
164
|
]
|
117
165
|
}
|
@@ -75,6 +75,18 @@
|
|
75
75
|
"description": "Empty string",
|
76
76
|
"string": ""
|
77
77
|
},
|
78
|
+
{
|
79
|
+
"description": "leading white space positive number",
|
80
|
+
"string": " 1"
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"description": "leading white space negative number",
|
84
|
+
"string": " -1"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"description": "trailing white space",
|
88
|
+
"string": "1 "
|
89
|
+
},
|
78
90
|
{
|
79
91
|
"description": "Invalid",
|
80
92
|
"string": "E"
|
@@ -267,6 +267,10 @@
|
|
267
267
|
"description": "[basx570] Near-specials (Conversion_syntax)",
|
268
268
|
"string": "9Inf"
|
269
269
|
},
|
270
|
+
{
|
271
|
+
"description": "[basx512] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
272
|
+
"string": "12 "
|
273
|
+
},
|
270
274
|
{
|
271
275
|
"description": "[basx517] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
272
276
|
"string": "12-"
|
@@ -17,6 +17,26 @@
|
|
17
17
|
"description": "Single-character key subdoc",
|
18
18
|
"canonical_bson": "160000000378000E0000000261000200000062000000",
|
19
19
|
"canonical_extjson": "{\"x\" : {\"a\" : \"b\"}}"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"description": "Dollar-prefixed key in sub-document",
|
23
|
+
"canonical_bson": "170000000378000F000000022461000200000062000000",
|
24
|
+
"canonical_extjson": "{\"x\" : {\"$a\" : \"b\"}}"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"description": "Dollar as key in sub-document",
|
28
|
+
"canonical_bson": "160000000378000E0000000224000200000061000000",
|
29
|
+
"canonical_extjson": "{\"x\" : {\"$\" : \"a\"}}"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"description": "Dotted key in sub-document",
|
33
|
+
"canonical_bson": "180000000378001000000002612E62000200000063000000",
|
34
|
+
"canonical_extjson": "{\"x\" : {\"a.b\" : \"c\"}}"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"description": "Dot as key in sub-document",
|
38
|
+
"canonical_bson": "160000000378000E000000022E000200000061000000",
|
39
|
+
"canonical_extjson": "{\"x\" : {\".\" : \"a\"}}"
|
20
40
|
}
|
21
41
|
],
|
22
42
|
"decodeErrors": [
|
@@ -50,31 +50,31 @@
|
|
50
50
|
"decodeErrors": [
|
51
51
|
{
|
52
52
|
"description": "bad symbol length: 0 (but no 0x00 either)",
|
53
|
-
"bson": "
|
53
|
+
"bson": "0C0000000E61000000000000"
|
54
54
|
},
|
55
55
|
{
|
56
56
|
"description": "bad symbol length: -1",
|
57
|
-
"bson": "
|
57
|
+
"bson": "0C0000000E6100FFFFFFFF00"
|
58
58
|
},
|
59
59
|
{
|
60
60
|
"description": "bad symbol length: eats terminator",
|
61
|
-
"bson": "
|
61
|
+
"bson": "100000000E6100050000006200620000"
|
62
62
|
},
|
63
63
|
{
|
64
64
|
"description": "bad symbol length: longer than rest of document",
|
65
|
-
"bson": "
|
65
|
+
"bson": "120000000E00FFFFFF00666F6F6261720000"
|
66
66
|
},
|
67
67
|
{
|
68
68
|
"description": "symbol is not null-terminated",
|
69
|
-
"bson": "
|
69
|
+
"bson": "100000000E610004000000616263FF00"
|
70
70
|
},
|
71
71
|
{
|
72
72
|
"description": "empty symbol, but extra null",
|
73
|
-
"bson": "
|
73
|
+
"bson": "0E0000000E610001000000000000"
|
74
74
|
},
|
75
75
|
{
|
76
76
|
"description": "invalid UTF-8",
|
77
|
-
"bson": "
|
77
|
+
"bson": "0E0000000E610002000000E90000"
|
78
78
|
}
|
79
79
|
]
|
80
80
|
}
|
@@ -3,9 +3,24 @@
|
|
3
3
|
"bson_type": "0x00",
|
4
4
|
"valid": [
|
5
5
|
{
|
6
|
-
"description": "
|
6
|
+
"description": "Dollar-prefixed key in top-level document",
|
7
7
|
"canonical_bson": "0F00000010246B6579002A00000000",
|
8
8
|
"canonical_extjson": "{\"$key\": {\"$numberInt\": \"42\"}}"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"description": "Dollar as key in top-level document",
|
12
|
+
"canonical_bson": "0E00000002240002000000610000",
|
13
|
+
"canonical_extjson": "{\"$\": \"a\"}"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"description": "Dotted key in top-level document",
|
17
|
+
"canonical_bson": "1000000002612E620002000000630000",
|
18
|
+
"canonical_extjson": "{\"a.b\": \"c\"}"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"description": "Dot as key in top-level document",
|
22
|
+
"canonical_bson": "0E000000022E0002000000610000",
|
23
|
+
"canonical_extjson": "{\".\": \"a\"}"
|
9
24
|
}
|
10
25
|
],
|
11
26
|
"decodeErrors": [
|
@@ -77,11 +92,11 @@
|
|
77
92
|
},
|
78
93
|
{
|
79
94
|
"description": "Bad $regularExpression (pattern is number, not string)",
|
80
|
-
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": 42, \"
|
95
|
+
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": 42, \"options\" : \"\"}}}"
|
81
96
|
},
|
82
97
|
{
|
83
98
|
"description": "Bad $regularExpression (options are number, not string)",
|
84
|
-
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": \"a\", \"
|
99
|
+
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": \"a\", \"options\" : 0}}}"
|
85
100
|
},
|
86
101
|
{
|
87
102
|
"description" : "Bad $regularExpression (missing pattern field)",
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# rubocop:todo all
|
1
2
|
# Copyright (C) 2009-2020 MongoDB Inc.
|
2
3
|
#
|
3
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -63,6 +64,28 @@ shared_examples_for "a JSON serializable object" do
|
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
67
|
+
shared_examples_for "an Extended JSON serializable object" do
|
68
|
+
|
69
|
+
it "serializes the Extended JSON from #as_extended_json" do
|
70
|
+
expect(object.to_extended_json).to eq(object.as_extended_json.to_json)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
shared_examples_for '#as_extended_json returns self' do
|
75
|
+
|
76
|
+
it 'returns self' do
|
77
|
+
expect(object.as_extended_json).to eq(object)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
shared_examples_for '#as_json calls #as_extended_json' do
|
82
|
+
|
83
|
+
it 'calls #as_extended_json' do
|
84
|
+
expect(object).to receive(:as_extended_json).with(no_args)
|
85
|
+
object.as_json
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
66
89
|
shared_examples_for "immutable when frozen" do |block|
|
67
90
|
|
68
91
|
context "when the document is frozen" do
|
@@ -122,7 +145,7 @@ shared_examples_for "a validated BSON key" do
|
|
122
145
|
end
|
123
146
|
end
|
124
147
|
|
125
|
-
context "when the string
|
148
|
+
context "when the string has dots/dollars" do
|
126
149
|
|
127
150
|
context "when the string starts with $" do
|
128
151
|
|
@@ -130,10 +153,10 @@ shared_examples_for "a validated BSON key" do
|
|
130
153
|
"$testing"
|
131
154
|
end
|
132
155
|
|
133
|
-
it "
|
156
|
+
it "does not raise an exception" do
|
134
157
|
expect {
|
135
158
|
validated
|
136
|
-
}.
|
159
|
+
}.to_not raise_error
|
137
160
|
end
|
138
161
|
end
|
139
162
|
|
@@ -143,10 +166,10 @@ shared_examples_for "a validated BSON key" do
|
|
143
166
|
"testing.testing"
|
144
167
|
end
|
145
168
|
|
146
|
-
it "
|
169
|
+
it "does not raise an exception" do
|
147
170
|
expect {
|
148
171
|
validated
|
149
|
-
}.
|
172
|
+
}.to_not raise_error
|
150
173
|
end
|
151
174
|
end
|
152
175
|
end
|
data/spec/support/spec_config.rb
CHANGED