-
-
Save kevinAlbs/fb9263040403a59c5610c6befdf59827 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test mongocryptd analysis of an insert to an int64 field. | |
// Run with: mongosh --port 27020 accept_int32_for_int64_field.js | |
// Sample output: | |
// Insert with NumberLong ... begin | |
// Insert with NumberLong ... end | |
// Insert with NumberInt ... begin | |
// MongoServerError: Cannot encrypt element of type int because schema requires that type is one of: [ long ] | |
const 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 | |
} | |
} | |
] | |
} | |
} | |
}; | |
console.log("Insert with NumberLong ... begin") | |
db.runCommand({ | |
"insert": "test", | |
"documents": [ | |
{ | |
"_id": 1, | |
"value": NumberLong("123") | |
} | |
], | |
"$db": "test", | |
"encryptionInformation": encryptionInformation | |
}) | |
console.log("Insert with NumberLong ... end") | |
console.log("Insert with NumberInt ... begin") | |
db.runCommand({ | |
"insert": "test", | |
"documents": [ | |
{ | |
"_id": 1, | |
"value": NumberInt("123") | |
} | |
], | |
"$db": "test", | |
"encryptionInformation": encryptionInformation | |
}) | |
console.log("Insert with NumberInt ... end") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment