diff --git a/rdb/Connection.php b/rdb/Connection.php index dcfdf63..5d7519c 100644 --- a/rdb/Connection.php +++ b/rdb/Connection.php @@ -271,7 +271,6 @@ public function run(Query $query, $options = array(), &$profile = '') } else { return $this->createCursorFromResponse($response, $token, $response['n'], $toNativeOptions); } - } public function continueQuery($token) diff --git a/rdb/Datum/NumberDatum.php b/rdb/Datum/NumberDatum.php index 82189ce..39513e8 100644 --- a/rdb/Datum/NumberDatum.php +++ b/rdb/Datum/NumberDatum.php @@ -9,13 +9,13 @@ class NumberDatum extends Datum { public function encodeServerRequest() { - return (float)$this->getValue(); + return $this->getValue(); } public static function decodeServerResponse($json) { $result = new NumberDatum(); - $result->setValue((float)$json); + $result->setValue($json); return $result; } diff --git a/rdb/DatumConverter.php b/rdb/DatumConverter.php index 055e3a9..eb67ada 100644 --- a/rdb/DatumConverter.php +++ b/rdb/DatumConverter.php @@ -158,7 +158,6 @@ public function canEncodeAsJson($v) } return false; - } public function wrapImplicitVar(Query $q) diff --git a/rdb/Queries/Aggregations/Group.php b/rdb/Queries/Aggregations/Group.php index 9357573..8a0dfa7 100644 --- a/rdb/Queries/Aggregations/Group.php +++ b/rdb/Queries/Aggregations/Group.php @@ -7,16 +7,22 @@ class Group extends ValuedQuery { - public function __construct(ValuedQuery $sequence, $groupOn) + public function __construct(ValuedQuery $sequence, $groupOn = array()) { if (!is_array($groupOn)) { $groupOn = array($groupOn); } + if (isset($groupOn['index'])) { $this->setOptionalArg('index', $this->nativeToDatum($groupOn['index'])); unset($groupOn['index']); } + if (isset($groupOn['multi'])) { + $this->setOptionalArg('multi', $this->nativeToDatum($groupOn['multi'])); + unset($groupOn['multi']); + } + $this->setPositionalArg(0, $sequence); $i = 1; foreach ($groupOn as $g) { diff --git a/rdb/ValuedQuery/ValuedQuery.php b/rdb/ValuedQuery/ValuedQuery.php index fd983a6..92554ad 100644 --- a/rdb/ValuedQuery/ValuedQuery.php +++ b/rdb/ValuedQuery/ValuedQuery.php @@ -214,7 +214,7 @@ public function distinct($opts = null) { return new Distinct($this, $opts); } - public function group($groupOn) + public function group($groupOn = array()) { return new Group($this, $groupOn); } diff --git a/tests/Functional/AggregationsTest.php b/tests/Functional/AggregationsTest.php index 1891c77..15e0c06 100644 --- a/tests/Functional/AggregationsTest.php +++ b/tests/Functional/AggregationsTest.php @@ -160,6 +160,7 @@ public function testGroupArray() ->ungroup() ->run($this->conn); + $this->assertEquals($expected, $this->toArray($res)); } diff --git a/tests/TestHelpers/createDb.php b/tests/TestHelpers/createDb.php index 4bbb782..91dd3ed 100644 --- a/tests/TestHelpers/createDb.php +++ b/tests/TestHelpers/createDb.php @@ -6,7 +6,7 @@ $db = getenv('RDB_DB'); $res = r\dbCreate($db)->run($conn); -if ($res['dbs_created'] !== 1.0) { +if ($res['dbs_created'] !== 1) { echo 'Error creating DB' . PHP_EOL; exit; }