Skip to content

Commit f9cfee2

Browse files
committed
* Change exceptionCode after merge pr
* Fix Docker for tests * Some type fix * Fix types: max_execution_time & setConnectTimeOut
1 parent 7e7e83d commit f9cfee2

File tree

7 files changed

+31
-17
lines changed

7 files changed

+31
-17
lines changed

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public function setTimeout(int $timeout)
191191
/**
192192
* @return float
193193
*/
194-
public function getTimeout(): float
194+
public function getTimeout(): int
195195
{
196196
return $this->settings()->getTimeOut();
197197
}

src/Settings.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ public function database($db)
9393
}
9494

9595
/**
96-
* @return float
96+
* @return int
9797
*/
98-
public function getTimeOut(): float
98+
public function getTimeOut(): int
9999
{
100-
return $this->get('max_execution_time');
100+
return intval($this->get('max_execution_time'));
101101
}
102102

103103
/**
@@ -172,10 +172,13 @@ public function makeSessionId()
172172
}
173173

174174
/**
175-
* @param float $time
175+
*
176+
* max_execution_time - is integer in Seconds clickhouse source
177+
*
178+
* @param int $time
176179
* @return $this
177180
*/
178-
public function max_execution_time(float $time)
181+
public function max_execution_time(int $time)
179182
{
180183
$this->set('max_execution_time',$time);
181184
return $this;
@@ -193,7 +196,7 @@ public function getSettings()
193196
* @param array $settings_array
194197
* @return $this
195198
*/
196-
public function apply($settings_array)
199+
public function apply(array $settings_array)
197200
{
198201
foreach ($settings_array as $key => $value) {
199202
$this->set($key, $value);
@@ -205,15 +208,15 @@ public function apply($settings_array)
205208
/**
206209
* @param int|bool $flag
207210
*/
208-
public function setReadOnlyUser($flag)
211+
public function setReadOnlyUser(mixed $flag):void
209212
{
210213
$this->_ReadOnlyUser = $flag;
211214
}
212215

213216
/**
214217
* @return bool
215218
*/
216-
public function isReadOnlyUser()
219+
public function isReadOnlyUser():bool
217220
{
218221
return $this->_ReadOnlyUser;
219222
}
@@ -222,7 +225,7 @@ public function isReadOnlyUser()
222225
* @param string $name
223226
* @return mixed|null
224227
*/
225-
public function getSetting($name)
228+
public function getSetting(string $name)
226229
{
227230
if (!isset($this->settings[$name])) {
228231
return null;

src/Transport/Http.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public function setConnectTimeOut(float $connectTimeOut)
423423
/**
424424
* get ConnectTimeOut in seconds
425425
*
426-
* @return int
426+
* @return float
427427
*/
428428
public function getConnectTimeOut(): float
429429
{

tests/ClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ public function testExceptionWrite()
780780
public function testExceptionInsert()
781781
{
782782
$this->expectException(QueryException::class);
783-
$this->expectExceptionCode(404);
783+
$this->expectExceptionCode(60); // Table default.ZZZZZ doesn't exist
784784

785785
$this->client->insert('bla_bla', [
786786
['HASH1', [11, 22, 33]],
@@ -799,7 +799,7 @@ public function testExceptionInsertNoData() : void
799799
public function testExceptionSelect()
800800
{
801801
$this->expectException(QueryException::class);
802-
$this->expectExceptionCode(404);
802+
$this->expectExceptionCode(60); // Table not exists
803803

804804
$this->client->select("SELECT * FROM XXXXX_SSS")->rows();
805805
}

tests/FormatQueryTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,27 @@ public function testCreateTableTEMPORARYNoSession()
5656

5757
public function testClientTimeoutSettings()
5858
{
59+
// https://github.com/smi2/phpClickHouse/issues/168
60+
// Only setConnectTimeOut & getConnectTimeOut can be float
61+
// max_execution_time - is integer in clickhouse source - Seconds
5962
$this->client->database('default');
6063

61-
$timeout = 0.55;
64+
$timeout = 0.55; // un support, "clickhouse source - Seconds"
6265
$this->client->setTimeout($timeout); // 1500 ms
6366
$this->client->select('SELECT 123,123 as ping ')->rows();
64-
$this->assertSame(intval($timeout), $this->client->getTimeout());
67+
$this->assertSame(intval($timeout), intval($this->client->getTimeout()));
6568

6669
$timeout = 10.0;
6770
$this->client->setTimeout($timeout); // 10 seconds
6871
$this->client->select('SELECT 123,123 as ping ')->rows();
6972
$this->assertSame(intval($timeout), $this->client->getTimeout());
7073

74+
75+
// getConnectTimeOut is curl, can be float
7176
$timeout = 5.14;
7277
$this->client->setConnectTimeOut($timeout); // 5 seconds
7378
$this->client->select('SELECT 123,123 as ping ')->rows();
74-
$this->assertSame(5, $this->client->getConnectTimeOut());
79+
$this->assertSame(5.14, $this->client->getConnectTimeOut());
7580
}
7681

7782

tests/docker-clickhouse/.gitignore

Whitespace-only changes.

tests/docker-compose.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
version: '3'
22
services:
3+
34
clickhouse-server:
4-
image: clickhouse/clickhouse-server
5+
image: clickhouse/clickhouse-server:21.9
56
hostname: clickhouse
67
container_name: clickhouse
78
ports:
89
- 9000:9000
910
- 8123:8123
11+
sysctls:
12+
net.core.somaxconn: 1024
13+
net.ipv4.tcp_syncookies: 0
14+
volumes:
15+
- "./docker-clickhouse:/var/lib/clickhouse"
1016
ulimits:
1117
nofile:
1218
soft: 262144

0 commit comments

Comments
 (0)