Skip to content

Commit

Permalink
MONGOCRYPT-494 rename queryType and algorithm from "range" to "rangeP…
Browse files Browse the repository at this point in the history
…review" (#499)

* rename "range" to "rangePreview" in test data

This matches server expectations for encryptedFields.

* update algorithm and query type
  • Loading branch information
kevinAlbs authored Nov 28, 2022
1 parent d55e2f8 commit c97093d
Show file tree
Hide file tree
Showing 30 changed files with 83 additions and 82 deletions.
11 changes: 6 additions & 5 deletions src/mongocrypt-ctx-encrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1810,7 +1810,7 @@ _fle2_finalize_explicit (mongocrypt_ctx_t *ctx, mongocrypt_binary_t *out)
marking.type = MONGOCRYPT_MARKING_FLE2_ENCRYPTION;
if (ctx->opts.query_type.set) {
switch (ctx->opts.query_type.value) {
case MONGOCRYPT_QUERY_TYPE_RANGE:
case MONGOCRYPT_QUERY_TYPE_RANGEPREVIEW:
case MONGOCRYPT_QUERY_TYPE_EQUALITY:
marking.fle2.type = MONGOCRYPT_FLE2_PLACEHOLDER_TYPE_FIND;
break;
Expand All @@ -1830,7 +1830,7 @@ _fle2_finalize_explicit (mongocrypt_ctx_t *ctx, mongocrypt_binary_t *out)
case MONGOCRYPT_INDEX_TYPE_NONE:
marking.fle2.algorithm = MONGOCRYPT_FLE2_ALGORITHM_UNINDEXED;
break;
case MONGOCRYPT_INDEX_TYPE_RANGE:
case MONGOCRYPT_INDEX_TYPE_RANGEPREVIEW:
marking.fle2.algorithm = MONGOCRYPT_FLE2_ALGORITHM_RANGE;
break;
default:
Expand Down Expand Up @@ -2446,7 +2446,7 @@ mongocrypt_ctx_explicit_encrypt_init (mongocrypt_ctx_t *ctx,
}

if (ctx->opts.index_type.set &&
ctx->opts.index_type.value == MONGOCRYPT_INDEX_TYPE_RANGE) {
ctx->opts.index_type.value == MONGOCRYPT_INDEX_TYPE_RANGEPREVIEW) {
if (!ctx->opts.contention_factor.set) {
return _mongocrypt_ctx_fail_w_msg (
ctx, "contention factor is required for range indexed algorithm");
Expand All @@ -2470,8 +2470,9 @@ mongocrypt_ctx_explicit_encrypt_init (mongocrypt_ctx_t *ctx,
bool matches = false;

switch (ctx->opts.query_type.value) {
case MONGOCRYPT_QUERY_TYPE_RANGE:
matches = (ctx->opts.index_type.value == MONGOCRYPT_INDEX_TYPE_RANGE);
case MONGOCRYPT_QUERY_TYPE_RANGEPREVIEW:
matches =
(ctx->opts.index_type.value == MONGOCRYPT_INDEX_TYPE_RANGEPREVIEW);
break;
case MONGOCRYPT_QUERY_TYPE_EQUALITY:
matches =
Expand Down
4 changes: 2 additions & 2 deletions src/mongocrypt-ctx-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ typedef enum {
typedef enum {
MONGOCRYPT_INDEX_TYPE_NONE = 1,
MONGOCRYPT_INDEX_TYPE_EQUALITY = 2,
MONGOCRYPT_INDEX_TYPE_RANGE = 3
MONGOCRYPT_INDEX_TYPE_RANGEPREVIEW = 3
} mongocrypt_index_type_t;

const char *
_mongocrypt_index_type_to_string (mongocrypt_index_type_t val);

typedef enum {
MONGOCRYPT_QUERY_TYPE_EQUALITY = 1,
MONGOCRYPT_QUERY_TYPE_RANGE = 2
MONGOCRYPT_QUERY_TYPE_RANGEPREVIEW = 2
} mongocrypt_query_type_t;

const char *
Expand Down
16 changes: 8 additions & 8 deletions src/mongocrypt-ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ mongocrypt_ctx_setopt_algorithm (mongocrypt_ctx_t *ctx,
ctx->opts.index_type.value = MONGOCRYPT_INDEX_TYPE_NONE;
ctx->opts.index_type.set = true;
} else if (mstr_eq_ignore_case (
algo_str, mstrv_lit (MONGOCRYPT_ALGORITHM_RANGE_STR))) {
ctx->opts.index_type.value = MONGOCRYPT_INDEX_TYPE_RANGE;
algo_str, mstrv_lit (MONGOCRYPT_ALGORITHM_RANGEPREVIEW_STR))) {
ctx->opts.index_type.value = MONGOCRYPT_INDEX_TYPE_RANGEPREVIEW;
ctx->opts.index_type.set = true;
} else {
char *error = bson_strdup_printf ("unsupported algorithm string \"%.*s\"",
Expand Down Expand Up @@ -1196,8 +1196,8 @@ mongocrypt_ctx_setopt_query_type (mongocrypt_ctx_t *ctx,
ctx->opts.query_type.value = MONGOCRYPT_QUERY_TYPE_EQUALITY;
ctx->opts.query_type.set = true;
} else if (mstr_eq_ignore_case (
qt_str, mstrv_lit (MONGOCRYPT_QUERY_TYPE_RANGE_STR))) {
ctx->opts.query_type.value = MONGOCRYPT_QUERY_TYPE_RANGE;
qt_str, mstrv_lit (MONGOCRYPT_QUERY_TYPE_RANGEPREVIEW_STR))) {
ctx->opts.query_type.value = MONGOCRYPT_QUERY_TYPE_RANGEPREVIEW;
ctx->opts.query_type.set = true;
} else {
char *error = bson_strdup_printf (
Expand All @@ -1217,8 +1217,8 @@ _mongocrypt_index_type_to_string (mongocrypt_index_type_t val)
return "None";
case MONGOCRYPT_INDEX_TYPE_EQUALITY:
return "Equality";
case MONGOCRYPT_INDEX_TYPE_RANGE:
return "Range";
case MONGOCRYPT_INDEX_TYPE_RANGEPREVIEW:
return "RangePreview";
default:
return "Unknown";
}
Expand All @@ -1230,8 +1230,8 @@ _mongocrypt_query_type_to_string (mongocrypt_query_type_t val)
switch (val) {
case MONGOCRYPT_QUERY_TYPE_EQUALITY:
return "Equality";
case MONGOCRYPT_QUERY_TYPE_RANGE:
return "Range";
case MONGOCRYPT_QUERY_TYPE_RANGEPREVIEW:
return "RangePreview";
default:
return "Unknown";
}
Expand Down
22 changes: 11 additions & 11 deletions src/mongocrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,10 @@ mongocrypt_ctx_setopt_algorithm (mongocrypt_ctx_t *ctx,
#define MONGOCRYPT_ALGORITHM_INDEXED_STR "Indexed"
/// String constant for setopt_algorithm "Unindexed" explicit encryption
#define MONGOCRYPT_ALGORITHM_UNINDEXED_STR "Unindexed"
/// String constant for setopt_algorithm "Range" explicit encryption
/// NOTE: The Range algorithm is experimental only. It is not intended for
/// public use.
#define MONGOCRYPT_ALGORITHM_RANGE_STR "Range"
/// String constant for setopt_algorithm "rangePreview" explicit encryption
/// NOTE: The RangePreview algorithm is experimental only. It is not intended
/// for public use.
#define MONGOCRYPT_ALGORITHM_RANGEPREVIEW_STR "RangePreview"


/**
Expand Down Expand Up @@ -916,7 +916,7 @@ mongocrypt_ctx_encrypt_init (mongocrypt_ctx_t *ctx,
* This method expects the passed-in BSON to be of the form:
* { "v" : BSON value to encrypt | FLE2RangeFindDriverSpec }
*
* FLE2RangeFindDriverSpec may only be used when query_type is "range".
* FLE2RangeFindDriverSpec may only be used when query_type is "rangePreview".
* FLE2RangeFindDriverSpec is a BSON document with one of these forms:
*
* 1. A Match Expression of this form:
Expand Down Expand Up @@ -1539,9 +1539,9 @@ mongocrypt_ctx_setopt_query_type (mongocrypt_ctx_t *ctx,
int len);

/**
* Set options for explicit encryption with the "range" algorithm.
* NOTE: The Range algorithm is experimental only. It is not intended for public
* use.
* Set options for explicit encryption with the "rangePreview" algorithm.
* NOTE: The RangePreview algorithm is experimental only. It is not intended for
* public use.
*
* @p opts is a BSON document of the form:
* {
Expand All @@ -1564,8 +1564,8 @@ mongocrypt_ctx_setopt_algorithm_range (mongocrypt_ctx_t *ctx,

/// String constants for setopt_query_type
#define MONGOCRYPT_QUERY_TYPE_EQUALITY_STR "equality"
// NOTE: The Range algorithm is experimental only. It is not intended for public
// use.
#define MONGOCRYPT_QUERY_TYPE_RANGE_STR "range"
// NOTE: The RangePreview algorithm is experimental only. It is not intended for
// public use.
#define MONGOCRYPT_QUERY_TYPE_RANGEPREVIEW_STR "rangePreview"

#endif /* MONGOCRYPT_H */
2 changes: 1 addition & 1 deletion test/data/fle2-find-range/date/encrypted-field-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"path": "encrypted",
"bsonType": "date",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-find-range/date/encrypted-payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"path": "encrypted",
"bsonType": "date",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-find-range/date/mongocryptd-reply.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"path": "encrypted",
"bsonType": "date",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-find-range/double/encrypted-field-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"path": "encrypted",
"bsonType": "double",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-find-range/double/encrypted-payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"path": "encrypted",
"bsonType": "double",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-find-range/double/mongocryptd-reply.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"path": "encrypted",
"bsonType": "double",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-find-range/int32/encrypted-field-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"path": "encrypted",
"bsonType": "int",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-find-range/int32/encrypted-payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"path": "encrypted",
"bsonType": "int",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-find-range/int32/mongocryptd-reply.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"path": "encrypted",
"bsonType": "int",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-find-range/int64/encrypted-field-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"path": "encrypted",
"bsonType": "long",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-find-range/int64/encrypted-payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"path": "encrypted",
"bsonType": "long",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-find-range/int64/mongocryptd-reply.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"path": "encrypted",
"bsonType": "int",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-insert-range/date/encrypted-field-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"path": "encrypted",
"bsonType": "date",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-insert-range/date/encrypted-payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"path": "encrypted",
"bsonType": "date",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-insert-range/date/mongocryptd-reply.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"path": "encrypted",
"bsonType": "long",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"path": "encrypted",
"bsonType": "double",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-insert-range/double/encrypted-payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"path": "encrypted",
"bsonType": "double",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/fle2-insert-range/double/mongocryptd-reply.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"path": "encrypted",
"bsonType": "long",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand Down
4 changes: 2 additions & 2 deletions test/data/fle2-insert-range/int32/encrypted-field-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"path": "encrypted",
"bsonType": "int",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand All @@ -25,4 +25,4 @@
}
]
}
}
}
4 changes: 2 additions & 2 deletions test/data/fle2-insert-range/int32/encrypted-payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"path": "encrypted",
"bsonType": "int",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand All @@ -42,4 +42,4 @@
}
}
}
}
}
4 changes: 2 additions & 2 deletions test/data/fle2-insert-range/int32/mongocryptd-reply.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"path": "encrypted",
"bsonType": "int",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand All @@ -50,4 +50,4 @@
}
},
"hasEncryptedPlaceholders": true
}
}
4 changes: 2 additions & 2 deletions test/data/fle2-insert-range/int64/encrypted-field-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"path": "encrypted",
"bsonType": "long",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand All @@ -25,4 +25,4 @@
}
]
}
}
}
4 changes: 2 additions & 2 deletions test/data/fle2-insert-range/int64/encrypted-payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"path": "encrypted",
"bsonType": "long",
"queries": {
"queryType": "range",
"queryType": "rangePreview",
"contention": {
"$numberInt": "0"
},
Expand All @@ -42,4 +42,4 @@
}
}
}
}
}
Loading

0 comments on commit c97093d

Please sign in to comment.