Skip to content

Commit

Permalink
add ability to use filters with #readRow() (#1679)
Browse files Browse the repository at this point in the history
  • Loading branch information
mackenziestarr authored and dwsupplee committed Feb 15, 2019
1 parent 0c2dfd5 commit bec28c8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Bigtable/src/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,7 @@ public function readRows(array $options = [])
public function readRow($rowKey, array $options = [])
{
return $this->readRows(
['rowKeys' => [$rowKey]],
$options + $this->options
['rowKeys' => [$rowKey]] + $options + $this->options
)
->readAll()
->current();
Expand Down
26 changes: 26 additions & 0 deletions Bigtable/tests/Unit/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,32 @@ public function testReadRow()
$this->assertNull($row);
}

public function testReadRowWithFilter()
{
$rowSet = new RowSet();
$rowSet->setRowKeys(['rk1']);
$rowFilter = Filter::pass();
$expectedArgs = $this->options + [
'rows' => $rowSet,
'filter' => $rowFilter->toProto()
];
$this->serverStream->readAll()
->shouldBeCalled()
->willReturn(
$this->arrayAsGenerator([])
);
$this->bigtableClient->readRows(self::TABLE_NAME, $expectedArgs)
->shouldBeCalled()
->willReturn(
$this->serverStream->reveal()
);
$args = [
'filter' => $rowFilter
];
$row = $this->table->readRow('rk1', $args);
$this->assertNull($row);
}

public function testReadRowsWithMultipleRowKeys()
{
$rowSet = new RowSet();
Expand Down

0 comments on commit bec28c8

Please sign in to comment.