Skip to content

Commit

Permalink
Pass settings actually (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod authored Jan 28, 2022
1 parent 52ea4e4 commit 54ff548
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Client/Http/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function prepareRequest(RequestOptions $requestOptions) : RequestInterfac
PHP_QUERY_RFC3986
);

return $this->requestFactory->createRequest('POST', $query)
return $this->requestFactory->createRequest('POST', $query === '' ? '' : '?' . $query)
->withBody($this->streamFactory->createStream($requestOptions->sql));
}
}
9 changes: 9 additions & 0 deletions tests/Client/SelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace SimPod\ClickHouseClient\Tests\Client;

use SimPod\ClickHouseClient\Exception\ServerError;
use SimPod\ClickHouseClient\Format\Json;
use SimPod\ClickHouseClient\Format\JsonCompact;
use SimPod\ClickHouseClient\Format\JsonEachRow;
Expand Down Expand Up @@ -130,4 +131,12 @@ public function providerJsonEachRow() : iterable
CLICKHOUSE,
];
}

public function testSettingsArePassed() : void
{
self::expectException(ServerError::class);
$this->expectExceptionMessage("DB::Exception: Database `non-existent` doesn't exist");

$this->client->select('SELECT 1', new JsonCompact(), ['database' => 'non-existent']);
}
}

0 comments on commit 54ff548

Please sign in to comment.