Skip to content

Commit d3bb53c

Browse files
committed
add exception if query is empty
1 parent d275e63 commit d3bb53c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Query/Query.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class Query
3030
*/
3131
public function __construct($sql,$degenerations=[])
3232
{
33+
if (!trim($sql))
34+
{
35+
throw new QueryException('Empty Query');
36+
}
3337
$this->sql = $sql;
3438
$this->degenerations=$degenerations;
3539
}

tests/ClientTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,14 @@ public function testSqlConditions()
613613
);
614614
}
615615

616+
617+
/**
618+
* @expectedException \ClickHouseDB\QueryException
619+
*/
620+
public function testWriteEmpty()
621+
{
622+
$this->db->write('');
623+
}
616624
/**
617625
*
618626
*/

0 commit comments

Comments
 (0)