Skip to content

Commit

Permalink
Cast keySet keys to arrays instead of wrapping them (#505)
Browse files Browse the repository at this point in the history
* cast keySet keys to arrays instead of wrapping them

* adds tests for keyset formatting
  • Loading branch information
bshaffer authored and dwsupplee committed May 19, 2017
1 parent 0632d3a commit f9fad9a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Spanner/Connection/Grpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ private function formatKeySet(array $keySet)
$keySet['keys'] = [];

foreach ($keys as $key) {
$keySet['keys'][] = $this->formatListForApi([$key]);
$keySet['keys'][] = $this->formatListForApi((array) $key);
}
}

Expand Down
28 changes: 28 additions & 0 deletions tests/unit/Spanner/Connection/GrpcTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public function methodProvider()
$keySetArgs = [];
$keySet = (new KeySet)
->deserialize($keySetArgs, $codec);
$keySetSingular = (new KeySet())
->deserialize(['keys' => [['values' => ['number_value' => 1]]]], $codec);
$keySetComposite = (new KeySet())
->deserialize(['keys' => [['values' => [['number_value' => 1], ['number_value' => 1]]]]], $codec);

$readWriteTransactionArgs = ['readWrite' => []];
$readWriteTransactionOptions = new TransactionOptions;
Expand Down Expand Up @@ -308,6 +312,30 @@ public function methodProvider()
],
[$sessionName, $tableName, $columns, $keySet, ['transaction' => $transactionSelector, 'userHeaders' => ['google-cloud-resource-prefix' => [$databaseName]]]]
],
[
'streamingRead',
[
'keySet' => ['keys' => [1]],
'transactionId' => $transactionName,
'session' => $sessionName,
'table' => $tableName,
'columns' => $columns,
'database' => $databaseName,
],
[$sessionName, $tableName, $columns, $keySetSingular, ['transaction' => $transactionSelector, 'userHeaders' => ['google-cloud-resource-prefix' => [$databaseName]]]]
],
[
'streamingRead',
[
'keySet' => ['keys' => [[1,1]]],
'transactionId' => $transactionName,
'session' => $sessionName,
'table' => $tableName,
'columns' => $columns,
'database' => $databaseName,
],
[$sessionName, $tableName, $columns, $keySetComposite, ['transaction' => $transactionSelector, 'userHeaders' => ['google-cloud-resource-prefix' => [$databaseName]]]]
],
// test read write
[
'beginTransaction',
Expand Down

0 comments on commit f9fad9a

Please sign in to comment.