[SERVER-13705] $lte and $gt Query Operators not working properly for String Comparisions Created: 24/Apr/14 Updated: 10/Dec/14 Resolved: 24/Apr/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.4.6 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical - P2 |
| Reporter: | Prajjwal | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | query | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Operating System: | ALL |
| Steps To Reproduce: | 1. Insert Some Names : ) ) ) ) ) 2. Query for documents using $lt Query Operator to get all the documents having "name" starting with A,B and C. Expected Output: { "_id" : ObjectId("5358dfdf8211b04a14804731"), "name" : "Adam" } { "_id" : ObjectId("5358dfe38211b04a14804732"), "name" : "Bob" } { "_id" : ObjectId("5358dfe78211b04a14804733"), "name" : "Charlie" }It did not return the document where name is "Charlie". Similarly: $gt operator to get all the documents where name starts with Character greater than C, the following query behaves improperly and returns Charlie too. which was not expected.
|
| Participants: |
| Description |
|
db version v2.4.6 |
| Comments |
| Comment by Matt Kangas [ 24/Apr/14 ] |
|
prajjwal1988, this is working as designed.
Perhaps you want to use a $regex? The BSON spec does not define sort order for types, but our implementation for String comparison is:
Here's the relevant comparison code in v2.6: Also relevant: |