Skip to content

Commit

Permalink
Fixes #86 - RunGrouping where Group("Field").Count() reductions a…
Browse files Browse the repository at this point in the history
…re values (#89)

* Resolves #89. Squash.
  • Loading branch information
bchavez authored Aug 18, 2016
1 parent 2e059b3 commit 1bad678
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## v2.3.12
* Issue #87 - Fixed missing `.User(user,pass)` parameters on `ConnectionPool` builder.
* Fixed some synchronous methods not unwrapping `AggregateException`.
* Issue #86 - Fixes `RunGrouping` where `Group("Field").Count()` reductions are values.

## v2.3.11
* Added `ConnectionPool.AnyOpen` to check if any node is available in the host pool.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A [**RethinkDB**](http://rethinkdb.com/) database driver written in C# with 100%
This driver is based on the *official* [Java Driver](https://github.com/rethinkdb/rethinkdb/tree/next/drivers/java). The basic mechanics and architecture of both drivers are the same. Except this **C#** driver is a bit more *cool*, *stylish* and *kick-ass*. :sunglasses:

###### Standout Features
* 1,000+ Unit Tests - Passes the same ***ReQL*** test battery as the [official drivers](http://rethinkdb.com/docs/install-drivers/).
* 1,200+ Unit Tests - This driver passes the same ***ReQL*** test harness as the [official drivers](http://rethinkdb.com/docs/install-drivers/).
* [Awesome documentation](https://github.com/bchavez/RethinkDb.Driver/wiki).
* [ReGrid Support](https://github.com/bchavez/RethinkDb.Driver/wiki/ReGrid-File-Storage) - Distributed Large Binary Storage

Expand Down
22 changes: 22 additions & 0 deletions Source/RethinkDb.Driver.Tests/ReQL/GitHubIssues.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
using Newtonsoft.Json;
Expand Down Expand Up @@ -229,6 +230,27 @@ public void issue_78_make_sure_jtoken_is_a_jtoken_too()
typeof(JArray).IsJToken().Should().Be(true);
typeof(JValue).IsJToken().Should().Be(true);
}


[Test]
public void issue_86_grouping_count_transforms_reduction()
{
var games = new[]
{
new Game {id = 2, player = "Bob", points = 15, type = "ranked"},
new Game {id = 5, player = "Alice", points = 7, type = "free"},
new Game {id = 12, player = "Alice", points = 2, type = "free"},
};

var result = R.Expr(games)
.Group("player")
.Count()
.RunGrouping<string, int>(conn);

var groupings = result.ToArray();
groupings[0].Items[0].Should().Be(2);
groupings[1].Items[0].Should().Be(1);
}
}

}
6 changes: 6 additions & 0 deletions Source/RethinkDb.Driver/Model/GroupedResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public GroupedResult(JToken key, JArray items)
this.Key = key.ToObject<TKey>(Converter.Serializer);
this.Items = items.ToObject<List<TElement>>(Converter.Serializer);
}
public GroupedResult(JToken key, JValue item)
{
this.Key = key.ToObject<TKey>(Converter.Serializer);
var value = item.ToObject<TElement>(Converter.Serializer);
this.Items = new List<TElement>() {value};
}

public IEnumerator<TElement> GetEnumerator()
{
Expand Down

0 comments on commit 1bad678

Please sign in to comment.