Hi, one of our endpoints accepts raw mongo query and I have encountered issue with regexes.
The filter definition is created by
var bson = BsonSerializer.Deserialize<BsonDocument>(query);
var definition = new BsonDocumentFilterDefinition<CellDo>(bson);
The query looks like this:
{
"description": {
"$regex": /\w*\.a\b/
}
}
But when the query is passed serializer throws an exception saying JSON reader expected a string but found '/\\w*\\.a\\b/'.
I tried to wrap regular expression in strings - the expression is treated as string so doesn’t really help and I have also wrapped the expression into RegEx call, but it just thrown exception JSON reader expected a string but found 'RegEx'.
The queries looks like this:
{
"description": {
"$regex": RegEx("/\w*\.a\b/")
}
}
{
"description": {
"$regex": RegEx(/\w*\.a\b/)
}
}
I wonder if this is a bug because similar calls with ISODate instead are working fine.
We are currently using mongo from docker image mongo:4.2.6-bionic
and MongoDB.Driver 2.10.3