diff --git a/README.md b/README.md index 540d86f..ad5c0ae 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ $config = [ ]; $db = new ClickHouseDB\Client($config); $db->database('default'); -$db->setTimeout(1.5); // 1500 ms +$db->setTimeout(1.5); // 1 second , support only Int value $db->setTimeout(10); // 10 seconds $db->setConnectTimeOut(5); // 5 seconds $db->ping(true); // if can`t connect throw exception @@ -788,7 +788,7 @@ $cli->ping(); $result=$cl->truncateTable('dbNane.TableName_sharded'); // get one active node ( random ) -$cl->activeClient()->setTimeout(0.01); +$cl->activeClient()->setTimeout(500); $cl->activeClient()->write("DROP TABLE IF EXISTS default.asdasdasd ON CLUSTER cluster2"); diff --git a/src/Client.php b/src/Client.php index 9f41aa6..8f10563 100644 --- a/src/Client.php +++ b/src/Client.php @@ -183,7 +183,7 @@ public function setHost($host) /** * @return Settings */ - public function setTimeout(float $timeout) + public function setTimeout(int $timeout) { return $this->settings()->max_execution_time($timeout); } diff --git a/src/Settings.php b/src/Settings.php index ca7f6a8..5e3369d 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -172,12 +172,12 @@ public function makeSessionId() } /** - * @param int|float $time + * @param int $time * @return $this */ public function max_execution_time($time) { - $this->set('max_execution_time', $time); + $this->set('max_execution_time', intval($time)); return $this; } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 8733bdd..0d15b11 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -918,13 +918,13 @@ public function testInsertTableTimeout() $this->create_table_summing_url_views(); - $this->client->setTimeout(0.01); + $this->client->settings()->set('max_execution_time',0.1); $stat = $this->client->insertBatchFiles('summing_url_views', $file_data_names, [ 'event_time', 'url_hash', 'site_id', 'views', 'v_00', 'v_55' ]); - $this->client->ping(); + } /** * diff --git a/tests/FormatQueryTest.php b/tests/FormatQueryTest.php index 6a73cd1..9e07651 100644 --- a/tests/FormatQueryTest.php +++ b/tests/FormatQueryTest.php @@ -58,16 +58,23 @@ public function testClientTimeoutSettings() { $this->client->database('default'); - $timeout = 1.5; + $timeout = 0.55; $this->client->setTimeout($timeout); // 1500 ms - $this->assertSame($timeout, $this->client->getTimeout()); + $this->client->select('SELECT 123,123 as ping ')->rows(); + $this->assertSame(intval($timeout), $this->client->getTimeout()); $timeout = 10.0; $this->client->setTimeout($timeout); // 10 seconds - $this->assertSame($timeout, $this->client->getTimeout()); + $this->client->select('SELECT 123,123 as ping ')->rows(); + $this->assertSame(intval($timeout), $this->client->getTimeout()); - $timeout = 5.0; + $timeout = 5.14; $this->client->setConnectTimeOut($timeout); // 5 seconds + $this->client->select('SELECT 123,123 as ping ')->rows(); $this->assertSame(5, $this->client->getConnectTimeOut()); } + + + + }