foursquare/fongo — pull request #8 by tobyclemson (2012-12-16 01:52:14+00:00)
Title: Distinct for key should return distinct values for that key, not objects containing those distinct values.

The current test for ```DBCollection.distinct(String key)``` does not represent the same contract as the Mongo Java driver equivalent:

```java
@Test
public void testDistinctQuery() {
DBCollection collection = newCollection();
collection.insert(new BasicDBObject("n", 1).append("_id", 1));
collection.insert(new BasicDBObject("n", 2).append("_id", 2));
collection.insert(new BasicDBObject("n", 3).append("_id", 3));
collection.insert(new BasicDBObject("n", 1).append("_id", 4));
collection.insert(new BasicDBObject("n", 1).append("_id", 5));
assertEquals(Arrays.asList(
new BasicDBObject("n", 1).append("_id", 1),
new BasicDBObject("n", 2).append("_id", 2),
new BasicDBObject("n", 3).append("_id", 3)
), collection.distinct("n"));
}
```

Instead of returning one of the objects containing each of the distinct values of 'n', just the values of 'n' should be returned in a list:

```java
@Test
public void testDistinctQuery() {
DBCollection collection = newCollection();
collection.insert(new BasicDBObject("n", 1).append("_id", 1));
collection.insert(new BasicDBObject("n", 2).append("_id", 2));
collection.insert(new BasicDBObject("n", 3).append("_id", 3));
collection.insert(new BasicDBObject("n", 1).append("_id", 4));
collection.insert(new BasicDBObject("n", 1).append("_id", 5));
assertEquals(Arrays.asList(1, 2, 3), collection.distinct("n"));
}
```

The attached pull request redefines the test as such and makes the relevant fix to ```FongoDBCollection```.