Skip to content

Commit

Permalink
feat: add settings param to insert calls (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod authored Oct 9, 2022
1 parent d7d6771 commit 87a91eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/Client/ClickHouseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ public function selectWithParams(string $query, array $params, Format $outputFor
/**
* @param array<array<mixed>> $values
* @param array<string>|null $columns
* @param array<string, float|int|string> $settings
*/
public function insert(string $table, array $values, array|null $columns = null): void;
public function insert(string $table, array $values, array|null $columns = null, array $settings = []): void;

/**
* @param array<string, float|int|string> $settings
* @param Format<O> $inputFormat
*
* @template O of Output
*/
public function insertWithFormat(string $table, Format $inputFormat, string $data): void;
public function insertWithFormat(string $table, Format $inputFormat, string $data, array $settings = []): void;
}
10 changes: 6 additions & 4 deletions src/Client/PsrClickHouseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function selectWithParams(string $query, array $params, Format $outputFor
/**
* {@inheritDoc}
*/
public function insert(string $table, array $values, array|null $columns = null): void
public function insert(string $table, array $values, array|null $columns = null, array $settings = []): void
{
if ($values === []) {
throw CannotInsert::noValues();
Expand Down Expand Up @@ -124,11 +124,12 @@ public function insert(string $table, array $values, array|null $columns = null)
INSERT INTO $table
$columnsSql
VALUES $valuesSql
CLICKHOUSE
CLICKHOUSE,
$settings
);
}

public function insertWithFormat(string $table, Format $inputFormat, string $data): void
public function insertWithFormat(string $table, Format $inputFormat, string $data, array $settings = []): void
{
$formatSql = $inputFormat::toSql();

Expand All @@ -137,7 +138,8 @@ public function insertWithFormat(string $table, Format $inputFormat, string $dat
$this->executeRequest(
<<<CLICKHOUSE
INSERT INTO $table $formatSql $data
CLICKHOUSE
CLICKHOUSE,
$settings
);
}

Expand Down

0 comments on commit 87a91eb

Please sign in to comment.