Skip to content

Instantly share code, notes, and snippets.

@kevinAlbs
Created May 6, 2019 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinAlbs/f57517ea0118415a503724702aa6e0de to your computer and use it in GitHub Desktop.
Save kevinAlbs/f57517ea0118415a503724702aa6e0de to your computer and use it in GitHub Desktop.
/*
* start mongocryptd, then do:
* mongo --port 27020 repro.js
*/
var schema = {
properties: {
ssn: {
encrypt: {
keyId: [
BinData(4, "AAAAAAAAAAAAAAAAAAAAAA==")
],
bsonType: "string",
algorithm: "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic",
initializationVector: BinData(0, "aWlpaWlpaWlpaWlpaWlpaQ==")
}
}
},
bsonType: "object"
};
var update_cmd =
{
update: "default",
updates: [
{ q: {},
u: { $set: {"y.$[i].b": 2} },
arrayFilters: [ {"i.b": 4} ]
}
],
ordered: true,
jsonSchema: schema
}
printjson(db.runCommand(update_cmd))
/*
Even though "y" is not an encrypted field, we get back:
{
"ok" : 0,
"errmsg" : "No array filter found for identifier 'i' in path 'y.$[i].b'",
"code" : 2,
"codeName" : "BadValue"
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment