Skip to content

Commit

Permalink
fix Call to undefined method PhpClickHouseLaravel\Builder::newQuery()
Browse files Browse the repository at this point in the history
  • Loading branch information
glushkovds committed Sep 28, 2023
1 parent a8d954c commit 4750699
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,9 @@ public function update(array $values): Statement
return $this->client->write($sql);
}

public function newQuery(): self
{
return new static($this->client);
}

}
9 changes: 9 additions & 0 deletions tests/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use PhpClickHouseLaravel\Builder;
use Tests\Models\Example;

class BaseTest extends TestCase
Expand Down Expand Up @@ -65,4 +66,12 @@ public function testPretendMigration()
$exist = $db->select("EXISTS $tableName")->fetchOne('result');
$this->assertEquals(0, $exist);
}

public function testOrWhere()
{
$query = Example::select()->where(function (Builder $q) {
$q->where('f_int', 1)->orWhere('f_int', 2);
});
$this->assertEquals("SELECT * FROM `examples` WHERE (`f_int` = 1 OR `f_int` = 2)", $query->toSql());
}
}

0 comments on commit 4750699

Please sign in to comment.