[CSHARP-540] Support Bitwise Operators in LINQ (and possibly Query) Created: 27/Jul/12 Updated: 20/Mar/14 Resolved: 30/Jul/12 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.5 |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Alexander Nagy | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | driver | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
All |
||
| Description |
|
It's a very common use case in SQL databases to want to perform bitwise operations during queries. While there the server doesn't offer these yet (there are open pull requests to add it), it would be useful if such logic could be implemented in the driver. Couple ways of doing this off the top of my head: } and (x & 3) != 0 would be { x : { $not: { $mod : [4, 0] } } } If one really wanted to exceed expectations, translating any sort of simple arithmetic computation to a JavaScript function would be fantastic and provide lasting value (type safe complex data analysis scenarios for one). |
| Comments |
| Comment by Craig Wilson [ 30/Jul/12 ] |
|
Since we can't support all the operations all the time, I think it would be confusing and frustrating for users if we only implemented the "convertible" operations. For instance, take the user who passes the right-side value from user input: (x & 2) == {user supplied value}. It works for some values the user supplies and throws on others. While emitting javascript is also possible, map/reduce is slow and not recommended for using in real-time queries. There is potential in the new aggregation framework but it doesn't support bitwise operations either. Finally, many of these operations can be rewritten in a way that is support by mongodb. So there is a workaround. I'm going to close this issue for the above reasons as not going to implement. |