Skip to content

Commit

Permalink
ignore CTE in statement for select or write method
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbaan committed Apr 15, 2021
1 parent 820c38b commit 19b0695
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ClickHouseStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,10 @@ public function getSql() : string
protected function processViaSMI2(string $sql) : void
{
$sql = trim($sql);
$withoutCte = preg_replace('/WITH(.*)SELECT/ms', 'SELECT', $sql);

$this->rows =
stripos($sql, 'select') === 0 ||
stripos($withoutCte, 'select') === 0 ||
stripos($sql, 'show') === 0 ||
stripos($sql, 'describe') === 0 ?
$this->smi2CHClient->select($sql)->rows() :
Expand Down

0 comments on commit 19b0695

Please sign in to comment.