-
Type: Bug
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: bson-4.7.0
What problem are you facing?
EJSON throws when trying to serialize a plain regexp with a /g flag, which the server does not support directly. bson deserializes/serializes this to an 's' flag instead: https://github.com/mongodb/js-bson/blob/853bbb0441b0e29e5277cd191b515d5a884d8d21/src/parser/serializer.ts#L226
What driver and relevant dependency versions are you using?
Latest js-bson
Steps to reproduce?
> bson.deserialize(bson.serialize({ a: /asdf/g })) { a: /asdf/g } > bson.EJSON.serialize({ a: /asdf/g }) Uncaught BSONError: The regular expression option [g] is not supported at new BSONError (/home/addaleax/src/mongosh/node_modules/bson/lib/error.js:23:28) at new BSONRegExp (/home/addaleax/src/mongosh/node_modules/bson/lib/regexp.js:37:23) at serializeValue (/home/addaleax/src/mongosh/node_modules/bson/lib/extended_json.js:200:18) at serializeDocument (/home/addaleax/src/mongosh/node_modules/bson/lib/extended_json.js:238:29) at serializeValue (/home/addaleax/src/mongosh/node_modules/bson/lib/extended_json.js:204:16) at stringify (/home/addaleax/src/mongosh/node_modules/bson/lib/extended_json.js:363:19) at Object.serialize (/home/addaleax/src/mongosh/node_modules/bson/lib/extended_json.js:375:27)
- is depended on by
-
COMPASS-6082 RegExp sometimes breaks Compass
- Waiting (Blocked)