Skip to content

Commit 87a91eb

Browse files
authored
feat: add settings param to insert calls (#173)
1 parent d7d6771 commit 87a91eb

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/Client/ClickHouseClient.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ public function selectWithParams(string $query, array $params, Format $outputFor
4242
/**
4343
* @param array<array<mixed>> $values
4444
* @param array<string>|null $columns
45+
* @param array<string, float|int|string> $settings
4546
*/
46-
public function insert(string $table, array $values, array|null $columns = null): void;
47+
public function insert(string $table, array $values, array|null $columns = null, array $settings = []): void;
4748

4849
/**
50+
* @param array<string, float|int|string> $settings
4951
* @param Format<O> $inputFormat
5052
*
5153
* @template O of Output
5254
*/
53-
public function insertWithFormat(string $table, Format $inputFormat, string $data): void;
55+
public function insertWithFormat(string $table, Format $inputFormat, string $data, array $settings = []): void;
5456
}

src/Client/PsrClickHouseClient.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function selectWithParams(string $query, array $params, Format $outputFor
9090
/**
9191
* {@inheritDoc}
9292
*/
93-
public function insert(string $table, array $values, array|null $columns = null): void
93+
public function insert(string $table, array $values, array|null $columns = null, array $settings = []): void
9494
{
9595
if ($values === []) {
9696
throw CannotInsert::noValues();
@@ -124,11 +124,12 @@ public function insert(string $table, array $values, array|null $columns = null)
124124
INSERT INTO $table
125125
$columnsSql
126126
VALUES $valuesSql
127-
CLICKHOUSE
127+
CLICKHOUSE,
128+
$settings
128129
);
129130
}
130131

131-
public function insertWithFormat(string $table, Format $inputFormat, string $data): void
132+
public function insertWithFormat(string $table, Format $inputFormat, string $data, array $settings = []): void
132133
{
133134
$formatSql = $inputFormat::toSql();
134135

@@ -137,7 +138,8 @@ public function insertWithFormat(string $table, Format $inputFormat, string $dat
137138
$this->executeRequest(
138139
<<<CLICKHOUSE
139140
INSERT INTO $table $formatSql $data
140-
CLICKHOUSE
141+
CLICKHOUSE,
142+
$settings
141143
);
142144
}
143145

0 commit comments

Comments
 (0)