Skip to content

Commit ff126c5

Browse files
Resolve merge conflicts
2 parents 7280983 + 49ade88 commit ff126c5

File tree

315 files changed

+95124
-536
lines changed

Some content is hidden

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

315 files changed

+95124
-536
lines changed

.github/workflows/check_schema_version.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ function get_schema_version() {
88
js-yaml $1 | jq -r .schemaVersion
99
}
1010

11+
function get_json_schema_url () {
12+
schemaVersion=$(get_schema_version "$1")
13+
schemaFile="source/unified-test-format/schema-$schemaVersion.json"
14+
cat "$schemaFile" | jq -r '.["$schema"]'
15+
}
16+
1117
function get_all_schemaVersion_defining_files () {
1218
# look for all yaml files with "schemaVersion: ["'][1-9]"
1319
grep --include=*.{yml,yaml} --files-with-matches --recursive --word-regexp --regexp="schemaVersion: [\"'][1-9]" source | \
@@ -20,7 +26,17 @@ function get_all_schemaVersion_defining_files () {
2026
for testFile in $(get_all_schemaVersion_defining_files)
2127
do
2228
schemaVersion=$(get_schema_version "$testFile")
23-
if ! ajvCheck=$(ajv -s "source/unified-test-format/schema-$schemaVersion.json" -d "$testFile"); then
29+
jsonSchemaURL=$(get_json_schema_url "$testFile")
30+
if [ "$jsonSchemaURL" = "https://json-schema.org/draft/2019-09/schema#" ]; then
31+
spec="draft2019"
32+
elif [ "$jsonSchemaURL" = "http://json-schema.org/draft-07/schema#" ]; then
33+
spec="draft7"
34+
else
35+
echo "Do not know how to validate $jsonSchemaURL"
36+
exit 1
37+
fi
38+
39+
if ! ajvCheck=$(ajv --spec="$spec" -s "source/unified-test-format/schema-$schemaVersion.json" -d "$testFile"); then
2440
exitCode=1
2541
fi
2642
echo "$ajvCheck using schema v$schemaVersion"

source/bson-binary-vector/tests/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,22 @@ means that two single bit vectors in which 7 bits are ignored do not match unles
101101
server does.
102102

103103
```python
104-
b1 = Binary.from_vector([0b10000000], BinaryVectorDtype.PACKED_BIT, padding=7)
105-
assert b1 == Binary(b'\x10\x07\x80', subtype=9) # This is effectively a roundtrip.
106-
v1 = Binary.as_vector(b1)
104+
b1 = Binary(b'\x10\x07\x80', subtype=9) # 1-bit vector with all 0 ignored bits.
105+
b2 = Binary(b'\x10\x07\xff', subtype=9) # 1-bit vector with all 1 ignored bits.
106+
b3 = Binary.from_vector([0b10000000], BinaryVectorDtype.PACKED_BIT, padding=7) # Same data as b1.
107107

108-
b2 = Binary.from_vector([0b11111111], BinaryVectorDtype.PACKED_BIT, padding=7)
109-
assert b2 == Binary(b'\x10\x07\xff', subtype=9)
108+
v1 = Binary.as_vector(b1)
110109
v2 = Binary.as_vector(b2)
110+
v3 = Binary.as_vector(b3)
111111

112112
assert b1 != b2 # Unequal at naive Binary level
113113
assert v2 != v1 # Also chosen to be unequal at BinaryVector level as [255] != [128]
114+
assert b1 == b3 # Equal at naive Binary level
115+
assert v1 == v3 # Equal at the BinaryVector level
114116
```
115117

116-
Drivers MAY skip this test if they choose not to implement a `Vector` type.
118+
Drivers MAY skip this test if they choose not to implement a `Vector` type, or the type does not support comparison, or
119+
the type cannot be constructed with non-zero ignored bits.
117120

118121
## FAQ
119122

source/client-side-encryption/client-side-encryption.md

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ QEv1 and QEv2 are incompatible.
4848
MongoDB 8.0 dropped `queryType=rangePreview` and added `queryType=range`
4949
([SPM-3583](https://jira.mongodb.org/browse/SPM-3583)).
5050

51+
MongoDB 8.2 added unstable support for QE text queries ([SPM-2880](https://jira.mongodb.org/browse/SPM-2880))
52+
5153
## META
5254

5355
The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
@@ -1256,6 +1258,7 @@ class EncryptOpts {
12561258
contentionFactor: Optional<Int64>,
12571259
queryType: Optional<String>
12581260
rangeOpts: Optional<RangeOpts>
1261+
textOpts: Optional<TextOpts>
12591262
}
12601263

12611264
// RangeOpts specifies index options for a Queryable Encryption field supporting "range" queries.
@@ -1273,6 +1276,48 @@ class RangeOpts {
12731276
// precision determines the number of significant digits after the decimal point. May only be set for double or decimal128.
12741277
precision: Optional<Int32>
12751278
}
1279+
1280+
// TextOpts specifies options for a Queryable Encryption field supporting text queries.
1281+
// NOTE: TextOpts is currently unstable API and subject to backwards breaking changes.
1282+
class TextOpts {
1283+
// substring contains further options to support substring queries.
1284+
substring: Optional<SubstringOpts>,
1285+
// prefix contains further options to support prefix queries.
1286+
prefix: Optional<PrefixOpts>,
1287+
// suffix contains further options to support suffix queries.
1288+
suffix: Optional<SuffixOpts>,
1289+
// caseSensitive determines whether text indexes for this field are case sensitive.
1290+
caseSensitive: bool,
1291+
// diacriticSensitive determines whether text indexes for this field are diacritic sensitive.
1292+
diacriticSensitive: bool
1293+
}
1294+
1295+
// NOTE: SubstringOpts is currently unstable API and subject to backwards breaking changes.
1296+
class SubstringOpts {
1297+
// strMaxLength is the maximum allowed length to insert. Inserting longer strings will error.
1298+
strMaxLength: Int32,
1299+
// strMinQueryLength is the minimum allowed query length. Querying with a shorter string will error.
1300+
strMinQueryLength: Int32,
1301+
// strMaxQueryLength is the maximum allowed query length. Querying with a longer string will error.
1302+
strMaxQueryLength: Int32,
1303+
}
1304+
1305+
// NOTE: PrefixOpts is currently unstable API and subject to backwards breaking changes.
1306+
class PrefixOpts {
1307+
// strMinQueryLength is the minimum allowed query length. Querying with a shorter string will error.
1308+
strMinQueryLength: Int32,
1309+
// strMaxQueryLength is the maximum allowed query length. Querying with a longer string will error.
1310+
strMaxQueryLength: Int32,
1311+
}
1312+
1313+
// NOTE: SuffixOpts is currently unstable API and subject to backwards breaking changes.
1314+
class SuffixOpts {
1315+
// strMinQueryLength is the minimum allowed query length. Querying with a shorter string will error.
1316+
strMinQueryLength: Int32,
1317+
// strMaxQueryLength is the maximum allowed query length. Querying with a longer string will error.
1318+
strMaxQueryLength: Int32,
1319+
}
1320+
12761321
```
12771322
12781323
Explicit encryption requires a key and algorithm. Keys are either identified by `_id` or by alternate name. Exactly one
@@ -1295,34 +1340,45 @@ One of the strings:
12951340
- "Indexed"
12961341
- "Unindexed"
12971342
- "Range"
1343+
- "TextPreview"
12981344
1299-
The result of explicit encryption with the "Indexed" or "Range" algorithm must be processed by the server to insert or
1300-
query. Drivers MUST document the following behavior:
1345+
The result of explicit encryption with the "Indexed", "Range", or "TextPreview" algorithm must be processed by the
1346+
server to insert or query. Drivers MUST document the following behavior:
13011347
1302-
> To insert or query with an "Indexed" or "Range" encrypted payload, use a `MongoClient` configured with
1348+
> To insert or query with an "Indexed", "Range", or "TextPreview" encrypted payload, use a `MongoClient` configured with
13031349
> `AutoEncryptionOpts`. `AutoEncryptionOpts.bypassQueryAnalysis` may be true. `AutoEncryptionOpts.bypassAutoEncryption`
1304-
> must be false.
1350+
> must be false. The "TextPreview" algorithm is in preview and should be used for experimental workloads only. These
1351+
> features are unstable and their security is not guaranteed until released as Generally Available (GA). The GA version
1352+
> of these features may not be backwards compatible with the preview version.
13051353
13061354
#### contentionFactor
13071355
1308-
contentionFactor may be used to tune performance. Only applies when algorithm is "Indexed" or "Range". libmongocrypt
1309-
returns an error if contentionFactor is set for a non-applicable algorithm.
1356+
contentionFactor may be used to tune performance. Only applies when algorithm is "Indexed", "Range", or "TextPreview".
1357+
libmongocrypt returns an error if contentionFactor is set for a non-applicable algorithm.
13101358
13111359
#### queryType
13121360
13131361
One of the strings:
13141362
13151363
- "equality"
13161364
- "range"
1365+
- "prefixPreview"
1366+
- "suffixPreview"
1367+
- "substringPreview"
13171368
1318-
queryType only applies when algorithm is "Indexed" or "Range". libmongocrypt returns an error if queryType is set for a
1319-
non-applicable queryType.
1369+
queryType only applies when algorithm is "Indexed", "Range", or "TextPreview". libmongocrypt returns an error if
1370+
queryType is set for a non-applicable algorithm.
13201371
13211372
#### rangeOpts
13221373
13231374
rangeOpts only applies when algorithm is "Range". libmongocrypt returns an error if rangeOpts is set for a
13241375
non-applicable algorithm.
13251376
1377+
#### textOpts
1378+
1379+
textOpts only applies when algorithm is "TextPreview". libmongocrypt returns an error if textOpts is set for a
1380+
non-applicable algorithm.
1381+
13261382
## User facing API: When Auto Encryption Fails
13271383
13281384
Auto encryption requires parsing the MongoDB query language client side (with the [mongocryptd](#mongocryptd) process or
@@ -2463,6 +2519,8 @@ explicit session parameter as described in the [Drivers Sessions Specification](
24632519

24642520
## Changelog
24652521

2522+
- 2025-08-06: Add `TextPreview` algorithm.
2523+
24662524
- 2024-02-19: Add custom options AWS credential provider.
24672525

24682526
- 2024-10-09: Add retry prose test.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"fields": [
3+
{
4+
"keyId": {
5+
"$binary": {
6+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7+
"subType": "04"
8+
}
9+
},
10+
"path": "encryptedText",
11+
"bsonType": "string",
12+
"queries": [
13+
{
14+
"queryType": "prefixPreview",
15+
"strMinQueryLength": {
16+
"$numberInt": "2"
17+
},
18+
"strMaxQueryLength": {
19+
"$numberInt": "10"
20+
},
21+
"caseSensitive": true,
22+
"diacriticSensitive": true
23+
},
24+
{
25+
"queryType": "suffixPreview",
26+
"strMinQueryLength": {
27+
"$numberInt": "2"
28+
},
29+
"strMaxQueryLength": {
30+
"$numberInt": "10"
31+
},
32+
"caseSensitive": true,
33+
"diacriticSensitive": true
34+
}
35+
]
36+
}
37+
]
38+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"fields": [
3+
{
4+
"keyId": {
5+
"$binary": {
6+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7+
"subType": "04"
8+
}
9+
},
10+
"path": "encryptedText",
11+
"bsonType": "string",
12+
"queries": [
13+
{
14+
"queryType": "substringPreview",
15+
"strMaxLength": {
16+
"$numberInt": "10"
17+
},
18+
"strMinQueryLength": {
19+
"$numberInt": "2"
20+
},
21+
"strMaxQueryLength": {
22+
"$numberInt": "10"
23+
},
24+
"caseSensitive": true,
25+
"diacriticSensitive": true
26+
}
27+
]
28+
}
29+
]
30+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"fields": [
3+
{
4+
"keyId": {
5+
"$binary": {
6+
"base64": "LOCALAAAAAAAAAAAAAAAAA==",
7+
"subType": "04"
8+
}
9+
},
10+
"path": "foo",
11+
"bsonType": "string"
12+
}
13+
]
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"foo": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
3+
}

0 commit comments

Comments
 (0)