Skip to content

Commit 7a3f70f

Browse files
authored
DRIVERS-3321 Restore "prefixPreview" and "suffixPreview" (#1954)
1 parent d30d717 commit 7a3f70f

7 files changed

Lines changed: 1214 additions & 18 deletions

File tree

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,9 +1348,9 @@ insert or query. Drivers MUST document the following behavior:
13481348
13491349
> To insert or query with an "Indexed", "Range", or "String" encrypted payload, use a `MongoClient` configured with
13501350
> `AutoEncryptionOpts`. `AutoEncryptionOpts.bypassQueryAnalysis` may be true. `AutoEncryptionOpts.bypassAutoEncryption`
1351-
> must be false. The "substringPreview" query type is in preview and should be used for experimental workloads only.
1352-
> This feature is unstable and its security is not guaranteed until released as Generally Available (GA). The GA version
1353-
> of this feature may not be backwards compatible with the preview version.
1351+
> must be false. The "prefixPreview", "suffixPreview", and "substringPreview" query types are in preview and should be
1352+
> used for experimental workloads only. This feature is unstable and its security is not guaranteed until released as
1353+
> Generally Available (GA). The GA version of this feature may not be backwards compatible with the preview version.
13541354
13551355
#### contentionFactor
13561356
@@ -1363,9 +1363,9 @@ One of the strings:
13631363
13641364
- "equality"
13651365
- "range"
1366-
- "prefix"
1366+
- "prefix" / "prefixPreview"
13671367
- Used for the `$encStrStartsWith` operator.
1368-
- "suffix"
1368+
- "suffix" / "suffixPreview"
13691369
- Used for the `$encStrEndsWith` operator.
13701370
- "substringPreview"
13711371
- Used for the `$encStrContains` operator.
@@ -2523,6 +2523,8 @@ explicit session parameter as described in the [Drivers Sessions Specification](
25232523

25242524
## Changelog
25252525

2526+
- 2026-06-17: Restore `prefixPreview` and `suffixPreview` as experimental.
2527+
25262528
- 2026-06-16: Update tests in response to server-side validation of payloads
25272529
([SERVER-91887](https://jira.mongodb.org/browse/SERVER-91887))
25282530

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
"contention": {
22+
"$numberLong": "0"
23+
},
24+
"caseSensitive": true,
25+
"diacriticSensitive": true
26+
},
27+
{
28+
"queryType": "suffixPreview",
29+
"strMinQueryLength": {
30+
"$numberInt": "2"
31+
},
32+
"strMaxQueryLength": {
33+
"$numberInt": "10"
34+
},
35+
"contention": {
36+
"$numberLong": "0"
37+
},
38+
"caseSensitive": true,
39+
"diacriticSensitive": true
40+
}
41+
]
42+
}
43+
]
44+
}

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

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3878,6 +3878,9 @@ create the following collections with majority write concern:
38783878
- `db.prefix-suffix-ci-di` using the `encryptedFields` option set to the contents of
38793879
[encryptedFields-prefix-suffix-ci-di.json](https://github.com/mongodb/specifications/tree/master/source/client-side-encryption/etc/data/encryptedFields-prefix-suffix-ci-di.json).
38803880
This step requires server 9.0.0+.
3881+
- `db.prefix-suffix-preview` using the `encryptedFields` option set to the contents of
3882+
[encryptedFields-prefix-suffix-preview.json](https://github.com/mongodb/specifications/tree/master/source/client-side-encryption/etc/data/encryptedFields-prefix-suffix-preview.json).
3883+
This step requires server pre-9.0.0.
38813884
- `db.substring` using the `encryptedFields` option set to the contents of
38823885
[encryptedFields-substring.json](https://github.com/mongodb/specifications/tree/master/source/client-side-encryption/etc/data/encryptedFields-substring.json)
38833886
- `db.substring-ci-di` using the `encryptedFields` option set to the contents of
@@ -3947,7 +3950,8 @@ class EncryptOpts {
39473950
}
39483951
```
39493952

3950-
Use `explicitEncryptedClient` to insert the following document into `db.prefix-suffix` with majority write concern:
3953+
Use `explicitEncryptedClient` to insert the following document into `db.prefix-suffix` (if created) and
3954+
`db.prefix-suffix-preview` (if created) with majority write concern:
39513955

39523956
```javascript
39533957
{ "_id": 0, "encryptedText": <encrypted 'foobarbaz'> }
@@ -3980,15 +3984,20 @@ Use `explicitEncryptedClient` to insert the following document into `db.substrin
39803984

39813985
#### Case 1: can find a document by prefix
39823986

3983-
This test case requires MongoDB server 9.0.0+ and libmongocrypt 1.19.0+.
3987+
Run this case multiple times with the following sets of parameters:
3988+
3989+
- `queryType=prefix` and `collection=prefix-suffix`
3990+
- Require server 9.0.0+ and libmongocrypt 1.19.0+.
3991+
- `queryType=prefixPreview` and `collection=prefix-suffix-preview`
3992+
- Require server pre-9.0.0 and libmongocrypt 1.19.1+.
39843993

39853994
Use `clientEncryption.encrypt()` to encrypt the string `"foo"` with the following `EncryptOpts`:
39863995

39873996
```typescript
39883997
class EncryptOpts {
39893998
keyId : <key1ID>,
39903999
algorithm: "String",
3991-
queryType: "prefix",
4000+
queryType: "<queryType>",
39924001
contentionFactor: 0,
39934002
stringOpts: StringOpts {
39944003
caseSensitive: true,
@@ -4001,7 +4010,7 @@ class EncryptOpts {
40014010
}
40024011
```
40034012

4004-
Use `explicitEncryptedClient` to run a "find" operation on the `db.prefix-suffix` collection with the following filter:
4013+
Use `explicitEncryptedClient` to run a "find" operation on the `db.<collection>` collection with the following filter:
40054014

40064015
```javascript
40074016
{ $expr: { $encStrStartsWith: {input: '$encryptedText', prefix: <encrypted 'foo'>} } }
@@ -4015,15 +4024,20 @@ Assert the following document is returned:
40154024

40164025
#### Case 2: can find a document by suffix
40174026

4018-
This test case requires MongoDB server 9.0.0+ and libmongocrypt 1.19.0+.
4027+
Run this case multiple times with the following sets of parameters:
4028+
4029+
- `queryType=suffix` and `collection=prefix-suffix`
4030+
- Require server 9.0.0+ and libmongocrypt 1.19.0+.
4031+
- `queryType=suffixPreview` and `collection=prefix-suffix-preview`
4032+
- Require server pre-9.0.0 and libmongocrypt 1.19.1+.
40194033

40204034
Use `clientEncryption.encrypt()` to encrypt the string `"baz"` with the following `EncryptOpts`:
40214035

40224036
```typescript
40234037
class EncryptOpts {
40244038
keyId : <key1ID>,
40254039
algorithm: "String",
4026-
queryType: "suffix",
4040+
queryType: "<queryType>",
40274041
contentionFactor: 0,
40284042
stringOpts: StringOpts {
40294043
caseSensitive: true,
@@ -4036,7 +4050,7 @@ class EncryptOpts {
40364050
}
40374051
```
40384052

4039-
Use `explicitEncryptedClient` to run a "find" operation on the `db.prefix-suffix` collection with the following filter:
4053+
Use `explicitEncryptedClient` to run a "find" operation on the `db.<collection>` collection with the following filter:
40404054

40414055
```javascript
40424056
{ $expr: { $encStrEndsWith: {input: '$encryptedText', suffix: <encrypted 'baz'>} } }
@@ -4050,15 +4064,20 @@ Assert the following document is returned:
40504064

40514065
#### Case 3: assert no document found by prefix
40524066

4053-
This test case requires MongoDB server 9.0.0+ and libmongocrypt 1.19.0+.
4067+
Run this case multiple times with the following sets of parameters:
4068+
4069+
- `queryType=prefix` and `collection=prefix-suffix`
4070+
- Require server 9.0.0+ and libmongocrypt 1.19.0+.
4071+
- `queryType=prefixPreview` and `collection=prefix-suffix-preview`
4072+
- Require server pre-9.0.0 and libmongocrypt 1.19.1+.
40544073

40554074
Use `clientEncryption.encrypt()` to encrypt the string `"baz"` with the following `EncryptOpts`:
40564075

40574076
```typescript
40584077
class EncryptOpts {
40594078
keyId : <key1ID>,
40604079
algorithm: "String",
4061-
queryType: "prefix",
4080+
queryType: "<queryType>",
40624081
contentionFactor: 0,
40634082
stringOpts: StringOpts {
40644083
caseSensitive: true,
@@ -4071,7 +4090,7 @@ class EncryptOpts {
40714090
}
40724091
```
40734092

4074-
Use `explicitEncryptedClient` to run a "find" operation on the `db.prefix-suffix` collection with the following filter:
4093+
Use `explicitEncryptedClient` to run a "find" operation on the `db.<collection>` collection with the following filter:
40754094

40764095
```javascript
40774096
{ $expr: { $encStrStartsWith: {input: '$encryptedText', prefix: <encrypted 'baz'>} } }
@@ -4081,15 +4100,20 @@ Assert that no documents are returned.
40814100

40824101
#### Case 4: assert no document found by suffix
40834102

4084-
This test case requires MongoDB server 9.0.0+ and libmongocrypt 1.19.0+.
4103+
Run this case multiple times with the following sets of parameters:
4104+
4105+
- `queryType=suffix` and `collection=prefix-suffix`
4106+
- Require server 9.0.0+ and libmongocrypt 1.19.0+.
4107+
- `queryType=suffixPreview` and `collection=prefix-suffix-preview`
4108+
- Require server pre-9.0.0 and libmongocrypt 1.19.1+.
40854109

40864110
Use `clientEncryption.encrypt()` to encrypt the string `"foo"` with the following `EncryptOpts`:
40874111

40884112
```typescript
40894113
class EncryptOpts {
40904114
keyId : <key1ID>,
40914115
algorithm: "String",
4092-
queryType: "suffix",
4116+
queryType: "<queryType>",
40934117
contentionFactor: 0,
40944118
stringOpts: StringOpts {
40954119
caseSensitive: true,
@@ -4102,7 +4126,7 @@ class EncryptOpts {
41024126
}
41034127
```
41044128

4105-
Use `explicitEncryptedClient` to run a "find" operation on the `db.prefix-suffix` collection with the following filter:
4129+
Use `explicitEncryptedClient` to run a "find" operation on the `db.<collection>` collection with the following filter:
41064130

41074131
```javascript
41084132
{ $expr: { $encStrEndsWith: {input: '$encryptedText', suffix: <encrypted 'foo'>} } }

0 commit comments

Comments
 (0)