Skip to content

Commit

Permalink
Add proxies for the remainder of the changed methods.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Aug 12, 2024
1 parent f33b51b commit ddee7f3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
4 changes: 1 addition & 3 deletions util/EndpointProxies/sql/closeCursorProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

return <<<'EOD'
/**
* Proxy function to closeCursor() to prevent BC break.
* This API will be removed in a future version. Use 'close' API instead.
* Note that the SQL close API takes the cursor in the body.
*
*
* $params['cursor'] = (string) The cursor given by the server
*
* @param array{'cursor': string} $params Associative array of parameters
Expand Down
28 changes: 28 additions & 0 deletions util/EndpointProxies/sql/explainProxy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

return <<<'EOD'
/**
* $params['query'] = (string) The SQL Query
*
* @param array{'query': string} $params Associative array of parameters
* @return array
*
* Note: Use of query parameter is deprecated. Pass it in `body` instead.
*/
public function explain(array $params): array
{
$endpointBuilder = $this->endpoints;
$body = $this->extractArgument($params, 'body');
$query = $this->extractArgument($params, 'query');
/** @var AbstractEndpoint $endpoint */
$endpoint = $endpointBuilder('Sql\Explain');
$endpoint->setBody(array_merge($body, [
'query' => $query,
]));
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
EOD;
32 changes: 32 additions & 0 deletions util/EndpointProxies/sql/queryProxy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

return <<<'EOD'
/**
* $params['query'] = (string) The SQL Query
* $params['format'] = (string) The response format
* $params['cursor'] = (string) The cursor given by the server
* $params['fetch_size'] = (int) The fetch size
*
* @param array{'query'?: string, 'cursor'?: string, 'fetch_size'?: int} $params Associative array of parameters
* @return array
*
* Note: Use of `query`, `cursor` and `fetch_size` parameters is deprecated. Pass them in `body` instead.
*
*/
public function query(array $params): array
{
$endpointBuilder = $this->endpoints;
/** @var AbstractEndpoint $endpoint */
$endpoint = $endpointBuilder('Sql\Query');
$body = $this->extractArgument($params, 'body');
$endpoint->setBody(array_merge($body, array_filter([
'query' => $this->extractArgument($params, 'query'),
'cursor' => $this->extractArgument($params, 'cursor'),
'fetch_size' => $this->extractArgument($params, 'fetch_size'),
])));
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
EOD;

0 comments on commit ddee7f3

Please sign in to comment.