[SERVER-4928] $regex query should assert if value is not a regex or a string Created: 10/Feb/12 Updated: 11/Jul/16 Resolved: 02/Dec/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.0.2 |
| Fix Version/s: | 2.5.5 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Robert Stam | Assignee: | Benety Goh |
| Resolution: | Done | Votes: | 0 |
| Labels: | neweng, pull-request, query_triage | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Tested on Windows 7 64-bit but should be the same on all platforms. |
||
| Operating System: | ALL |
| Participants: |
| Description |
|
To reproduce: > db.test.remove() ) ) > The intent of the query was to return documents where t starts with "x" or "y", but the query is malformed. However, the server doesn't return any sort of error message and instead appears to just return all documents in the collection. The server should return an error message if the value of $regex is not a regular expression or a string. |
| Comments |
| Comment by Benety Goh [ 27/Nov/13 ] |
|
Assertion is implemented in new matcher implementation here: https://github.com/mongodb/mongo/blob/master/src/mongo/db/matcher/expression_parser.cpp#L522 |
| Comment by Shannon Weyrick [ 04/Jun/12 ] |
|
Patch up for comments here: |