[SERVER-11444] $lt/$lte/$gte/$gt behaves differently with array operand Created: 29/Oct/13 Updated: 17/Oct/16 Resolved: 07/Feb/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.4.5 |
| Fix Version/s: | 2.6.0-rc0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Alvin Richards (Inactive) | Assignee: | Benety Goh |
| Resolution: | Done | Votes: | 0 |
| Labels: | 26qa, nqf, query_triage | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
> db.serverBuildInfo( ) |
||
| Attachments: |
|
||||||||||||||||||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Major Change | ||||||||||||||||||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
{$gt: [X]} matches arrays in 2.4.8 but not in 2.5.3. This is a change in the matcher behavior when the operand to the inequality operator is an array. In 2.4.8, the matching behavior is affected by the level of nesting of the array. In 2.5.3, the matcher returns zero documents as long as the element in the collection is an array. -------------------- Problem: NOTE: It appears that 2.5.4-Pre deals with this case correctly, if confirmed then this becomes a DOC tickets to list the changed behaviour. Reproduce:
2.4.5
2.5.4-Pre returns all documents
It appears that 2.4.x does not deal with the [ [ value ] ] case correctly. |
| Comments |
| Comment by Benety Goh [ 07/Feb/14 ] | ||||||||||||||||||||||||||||||
|
inequality operators (lt/lte/gte/gt) now rely on compareElements to compare BSON elements just like other BSON types. unit tests in matcher updated to demonstrate current behavior. | ||||||||||||||||||||||||||||||
| Comment by Githook User [ 07/Feb/14 ] | ||||||||||||||||||||||||||||||
|
Author: {u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}Message: | ||||||||||||||||||||||||||||||
| Comment by Eliot Horowitz (Inactive) [ 03/Feb/14 ] | ||||||||||||||||||||||||||||||
|
The 2.4 behavior is correct. Fundamentally
How to compare arrays: Take lowest element from each array, and compare. For example:
You can evaluate that as is [0] less than any element of c's array. | ||||||||||||||||||||||||||||||
| Comment by Andrew Emil (Inactive) [ 27/Jan/14 ] | ||||||||||||||||||||||||||||||
|
Another example:
Nothing is returned in 2.5, but in 2.4 the document is returned | ||||||||||||||||||||||||||||||
| Comment by Andrew Emil (Inactive) [ 19/Nov/13 ] | ||||||||||||||||||||||||||||||
|
A super simple repro case: >db.test.insert( {c: [[1]]}) on 2.4 you get the inserted doc back, but on 2.5, nothing | ||||||||||||||||||||||||||||||
| Comment by Benety Goh [ 15/Nov/13 ] | ||||||||||||||||||||||||||||||
|
Re-opened for further discussion | ||||||||||||||||||||||||||||||
| Comment by Mathias Stearn [ 15/Nov/13 ] | ||||||||||||||||||||||||||||||
|
eliot I'm concerned about this being closed with $gte and $lte not matching arrays. That means that $gte doesn't return a superset of the document returned by equality matching (filed as | ||||||||||||||||||||||||||||||
| Comment by Benety Goh [ 15/Nov/13 ] | ||||||||||||||||||||||||||||||
|
inequality operators ($lt, $lte, $gte, $gt) do not match elements when the operand is an array: Example:
| ||||||||||||||||||||||||||||||
| Comment by Benety Goh [ 15/Nov/13 ] | ||||||||||||||||||||||||||||||
|
new test script without $nor and date types | ||||||||||||||||||||||||||||||
| Comment by Daniel Pasette (Inactive) [ 30/Oct/13 ] | ||||||||||||||||||||||||||||||
|
In 2.4.7, seems to also depend on the data type. Numbers are behaving slightly differently. Looks like this is a bug fixed in 2.5.4. With the following docs:
Results depend on level of nesting:
|