Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Transport/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,16 +618,16 @@ private function prepareSelect($sql, $bindings, $whereInFile, $writeToFile = nul
* @return CurlerRequest
* @throws \ClickHouseDB\Exception\TransportException
*/
private function prepareWrite($sql, $bindings = []): CurlerRequest
private function prepareWrite($sql, $bindings = [], ?string $forceResponseFormat = null): CurlerRequest
{
if ($sql instanceof Query) {
return $this->getRequestWrite($sql);
}

$query = $this->prepareQuery($sql, $bindings);

if (strpos($sql, 'CREATE') === 0 || strpos($sql, 'DROP') === 0 || strpos($sql, 'ALTER') === 0) {
$query->setFormat('JSON');
if (null !== $forceResponseFormat) {
$query->setFormat($forceResponseFormat);
}

return $this->getRequestWrite($query);
Expand Down Expand Up @@ -689,9 +689,9 @@ public function setProgressFunction(callable $callback) : void
* @return Statement
* @throws \ClickHouseDB\Exception\TransportException
*/
public function write($sql, array $bindings = [], $exception = true): Statement
public function write($sql, array $bindings = [], $exception = true, ?string $forceResponseFormat = null): Statement
{
$request = $this->prepareWrite($sql, $bindings);
$request = $this->prepareWrite($sql, $bindings, $forceResponseFormat);
$this->_curler->execOne($request);
$response = new Statement($request);
if ($exception) {
Expand Down