foam-framework / foam-framework/foam
Adding 'orderBy' causing incorrect query results to be returned.
- Dominant language
- JavaScript
- Stars
- 783
- Forks
- 51
- PR merge metrics
- No merged PRs in 30d
Description
_From [mr.g.e.a...@gmail.com](https://code.google.com/u/117819506376541286713/) on December 27, 2013 13:49:28_
Steps will reproduce the problem:
1. Run this sample code:
```
var Direction = FOAM({
model_: 'Model',
name: 'Direction',
ids: ['directionID'],
properties: [
{ name: 'directionID', model_: 'IntegerProperty'},
{ name: 'directionCode', model_: 'IntegerProperty'},
{ name: 'directionGroup', model_: 'IntegerProperty'},
]
});
var directions = MDAO.create({model: Direction})
.addIndex(Direction.DIRECTION_CODE)
.addIndex(Direction.DIRECTION_GROUP);
// Initial Data
directions.put(Direction.create({directionID: 1, directionCode: 1, directionGroup: 100}));
directions.put(Direction.create({directionID: 2, directionCode: 1, directionGroup: 100}));
directions.put(Direction.create({directionID: 3, directionCode: -1, directionGroup: 900}));
directions.put(Direction.create({directionID: 4, directionCode: -1, directionGroup: 900}));
directions.put(Direction.create({directionID: 5, directionCode: 2, directionGroup: 500}));
var selection = directions
.where(IN(Direction.DIRECTION_GROUP, [900]))
.where(EQ(Direction.DIRECTION_CODE, -1))
.where(EQ(Direction.DIRECTION_ID, 3));
selection
.select(function(data) { console.log("[plain] ID: " + data.directionID); });
selection
.orderBy(Direction.DIRECTION_GROUP)
.select(function(data) { console.log("[ordered] ID: " + data.directionID); });
```
Expected output:
```
[plain] ID: 3
[ordered] ID: 3
```
Actual output:
```
[plain] ID: 3
[ordered] ID: 3
[ordered] ID: 4
```
Tested on:
```
Google Chrome Version 31.0.1650.63 m
```
_Original issue: http://code.google.com/p/foam-framework/issues/detail?id=139_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.