Skip to content

Commit 54ff548

Browse files
authored
Pass settings actually (#146)
1 parent 52ea4e4 commit 54ff548

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Client/Http/RequestFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function prepareRequest(RequestOptions $requestOptions) : RequestInterfac
3333
PHP_QUERY_RFC3986
3434
);
3535

36-
return $this->requestFactory->createRequest('POST', $query)
36+
return $this->requestFactory->createRequest('POST', $query === '' ? '' : '?' . $query)
3737
->withBody($this->streamFactory->createStream($requestOptions->sql));
3838
}
3939
}

tests/Client/SelectTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace SimPod\ClickHouseClient\Tests\Client;
66

7+
use SimPod\ClickHouseClient\Exception\ServerError;
78
use SimPod\ClickHouseClient\Format\Json;
89
use SimPod\ClickHouseClient\Format\JsonCompact;
910
use SimPod\ClickHouseClient\Format\JsonEachRow;
@@ -130,4 +131,12 @@ public function providerJsonEachRow() : iterable
130131
CLICKHOUSE,
131132
];
132133
}
134+
135+
public function testSettingsArePassed() : void
136+
{
137+
self::expectException(ServerError::class);
138+
$this->expectExceptionMessage("DB::Exception: Database `non-existent` doesn't exist");
139+
140+
$this->client->select('SELECT 1', new JsonCompact(), ['database' => 'non-existent']);
141+
}
133142
}

0 commit comments

Comments
 (0)