[CSHARP-840] Query.Not does not handle $where correctly Created: 10/Oct/13 Updated: 02/Apr/15 Resolved: 19/Oct/13 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.8.3 |
| Fix Version/s: | 1.9 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Roman Kuzmin | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Major Change |
| Description |
|
There is a mistake in the method Not() of MongoDB.Driver.Builders.Query. Line: Presumably there should be "$not" instead of "$ne". Now a valid Where query { "$where" : { "$code" : "this.Length == null" }} is converted by Not() into invalid { "$where" : { "$ne" : { "$code" : "this.Length == null" }} } which fails with an error: $where expression has an unexpected type (response: { "errmsg" : "exception: $where expression has an unexpected type", "code" : 15902, "ok" : 0.0 }) Driver version 1.8.3 |
| Comments |
| Comment by auto [ 19/Oct/13 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}Message: |
| Comment by auto [ 19/Oct/13 ] |
|
Author: {u'username': u'rstam', u'name': u'Robert Stam', u'email': u'robert@10gen.com'}Message: |
| Comment by auto [ 19/Oct/13 ] |
|
Author: {u'username': u'rstam', u'name': u'Robert Stam', u'email': u'robert@10gen.com'}Message: |
| Comment by Robert Stam [ 11/Oct/13 ] |
|
In code review. Branch: |
| Comment by Robert Stam [ 10/Oct/13 ] |
|
I think the bug is that we assume that anything that doesn't match all the tests above that line must be an equality comparison, which as you have shown isn't always true. When we fix this we will also be sure to be more robust in the face of any future query operators that are introduced. Thanks for report this. |
| Comment by Roman Kuzmin [ 10/Oct/13 ] |
|
Or, if "$ne" still makes sense for other cases, then a special case for negation of $where should be added. |