-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Field Level Encryption, Queryable Encryption
-
Query Integration
Proposal
- Always accept int32 values for an int64 field. Convert the int32 to int64.
- Sometimes accept int64 values for an int32 field. Convert the int64 to int32 if the int64 is in range of an int32.
Background & Motivation
Query Analysis (mongocryptd / crypt_shared) returns an error if the value type being analyzed does not exactly match the bsonType from encryptedFields. Example:
// run this on mongocryptd: db.runCommand({ "insert": "test", "documents": [ { "_id": 1, "value": NumberInt("123") } ], "$db": "test", "encryptionInformation": { "type": 1, "schema": { "test.test": { "escCollection": "enxcol_.test.esc", "ecocCollection": "enxcol_.test.ecoc", "fields": [ { "keyId": UUID("b337ba84-68ec-4df5-b711-6e87bcfb9096"), "path": "value", "bsonType": "long", "queries": { "queryType": "equality", "contention": 0 } } ] } } } }) // Results in: MongoServerError: Cannot encrypt element of type int because schema requires that type is one of: [ long ]
This gist includes an example to run against mongocryptd.
Some driver languages do not have a straightforward way to specify int32 and int64. This is noted in this slack conversation https://mongodb.slack.com/archives/C0406ECL478/p1681098681664019:
> Does PHP provide a way to specify the numeric type being encoded?
Not through any user-friendly API. For our internal needs, we reconstruct an Int64 object.
- is related to
-
SERVER-77264 Verify that integer types are interchangeable for queryable encryption range preview
- Closed