[MONGOCRYPT-505] Add context initializer for encryptExpression Created: 04/Dec/22  Updated: 28/Oct/23  Resolved: 07/Dec/22

Status: Closed
Project: Libmongocrypt
Component/s: None
Affects Version/s: None
Fix Version/s: 1.7.0, 1.7.0-alpha1

Type: Task Priority: Unknown
Reporter: Kevin Albertson Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: libmongocrypt Support for Range Index
Binding Changes: Not Needed

 Description   

Summary

  • Add a new context initializer to support ClientEncryption.encryptExpression().
    • Require queryType to be "rangePreview"
  • Error if queryType "rangePreview" is passed to the context for ClientEncryption.Encrypt().

Background & Motivation

The DBX Scope: Driver Support for Range Index currently proposes this API:

   // encryptExpression encrypts an expression to query a range index.
   // `expr` is expected to be a BSON document of one of the following forms:
   // 1. A Match Expression of this form:
   //   {$and: [{<field>: {$gt: <value1>}}, {<field>: {$lt: <value2> }}]}
   // 2. An Aggregate Expression of this form:
   //   {$and: [{$gt: [<fieldpath>, <value1>]}, {$lt: [<fieldpath>, <value2>]}]
   // $gt may also be $gte. $lt may also be $lte.
   // Only supported for queryType "rangePreview"
   encryptExpression(expr: BsonDocument, opts: EncryptOpts): BsonDocument;

ClientEncryption.Encrypt() uses mongocrypt_ctx_explicit_encrypt_init.

mongocrypt_ctx_explicit_encrypt_init currently supports encrypting the Match Expression or Aggregate Expression, and returns a BSON document.

A separate initializer (perhaps named mongocrypt_ctx_explicit_encrypt_expression_init) can mirror the driver API. It can check for the required queryType=rangePreview.



 Comments   
Comment by Githook User [ 07/Dec/22 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: MONGOCRYPT-505 add mongocrypt_ctx_explicit_encrypt_expression_init (#509)

Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Branch: master
https://github.com/mongodb/libmongocrypt/commit/4a520d7cccee09d3d4ce4cec207701f31e050c7e

Generated at Thu Feb 08 09:08:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.