[CSHARP-1950] Allow string or regular expressions in values for $in with string Created: 23/Mar/17 Updated: 07/Jul/22 Resolved: 26/May/22 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Linq, LINQ3 |
| Affects Version/s: | 2.4.3 |
| Fix Version/s: | 2.16.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Ssemi Seol | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 2 |
| Labels: | triaged | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
using mongo csharp driver 2.4.3 |
||
| Issue Links: |
|
||||||||
| Epic Link: | CSHARP-3615 | ||||||||
| Description |
|
When trying to parse the following query:
another ways
I wanted the following results.
But the result is ...
using BsonRegularExpression in `$in` command https://docs.mongodb.com/manual/reference/operator/query/in/ I want to use regex in '$in' command.. |
| Comments |
| Comment by Githook User [ 26/May/22 ] | |||||||||||||||||||||
|
Author: {'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}Message: | |||||||||||||||||||||
| Comment by Damian Jaszczurowski [ 30/Mar/19 ] | |||||||||||||||||||||
|
what's the status of this? I'm using 2.7.0 and I experience the same problem. It wouldn't be a big problem but I heave heavy documents and when I manually deserialize it from BsonDocument this makes entire process less performant. | |||||||||||||||||||||
| Comment by Kevin Fairs [ 21/Dec/17 ] | |||||||||||||||||||||
|
What is the situation with this? We have extensive code using this pattern and running OK using the v2.4.0 driver, but unable to upgrade as broken in later versions. I see it is still not resolved in v2.5.0. Will a fix be imminent or do we have to re-write our code due to a breaking change? | |||||||||||||||||||||
| Comment by Robert Stam [ 23/Mar/17 ] | |||||||||||||||||||||
|
Thanks for reporting this. This is a side effect of the driver using the field serializer to serialize values. In order to do that, an attempt is made to convert the supplied value to the type of the field. In this case, a BsonRegularExpression can be converted to a string, which results in the regular expressions being serialized as strings. A minimal reproduction is:
The desired query is:
But the actual (incorrect) result is:
And a similar scenario using LINQ is:
|