Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ jobs:
- "8.4"
- "8.5"
clickhouse-version:
- "23.3"
- "23.8"
- "24.3"
- "24.8"
- "25.3"
- "25.8"
- "26.3"
dependency-versions:
- "highest"
env:
Expand Down
7 changes: 7 additions & 0 deletions src/Param/ParamValueConverterRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
'decimal256',
'enum',
'json',
'time',
'time64',
];

/** @phpstan-var ConverterRegistry */
Expand Down Expand Up @@ -109,7 +111,11 @@ public function __construct(array $registry = [])
throw UnsupportedParamValue::type($value);
},

'time' => self::noopConverter(),
'time64' => self::noopConverter(),

'BFloat16' => self::noopConverter(),
'QBit' => self::noopConverter(),

'Dynamic' => self::noopConverter(),
'Variant' => self::noopConverter(),
Expand Down Expand Up @@ -196,6 +202,7 @@ public function __construct(array $registry = [])
array_map($formatPolygonOrMultiLineString, $vv),
));
})($v),
'Geometry' => self::noopConverter(),

'Array' => fn (array|string $v, Type $type) => is_string($v)
? $v
Expand Down
30 changes: 20 additions & 10 deletions tests/Client/InsertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use SimPod\ClickHouseClient\Format\JsonCompact;
use SimPod\ClickHouseClient\Format\JsonEachRow;
use SimPod\ClickHouseClient\Format\RowBinary;
use SimPod\ClickHouseClient\Tests\ClickHouseVersion;
use SimPod\ClickHouseClient\Tests\TestCaseBase;
use SimPod\ClickHouseClient\Tests\WithClient;

Expand Down Expand Up @@ -50,17 +51,21 @@ public function testInsert(string $tableSql): void
new JsonEachRow(),
);

$data[0]['UserID'] = (string) $data[0]['UserID'];
$data[1]['UserID'] = (string) $data[1]['UserID'];
if (ClickHouseVersion::get() < 2508) {
$data[0]['UserID'] = (string) $data[0]['UserID'];
$data[1]['UserID'] = (string) $data[1]['UserID'];
}

self::assertSame($data, $output->data);
}

#[DataProvider('providerInsert')]
public function testInsertUseColumns(string $tableSql): void
{
$userId = ClickHouseVersion::get() >= 2508 ? 4324182021466249494 : '4324182021466249494';
$expectedData = [
['PageViews' => 5, 'UserID' => '4324182021466249494', 'Duration' => 146, 'Sign' => -1],
['PageViews' => 6, 'UserID' => '4324182021466249494', 'Duration' => 185, 'Sign' => 1],
['PageViews' => 5, 'UserID' => $userId, 'Duration' => 146, 'Sign' => -1],
['PageViews' => 6, 'UserID' => $userId, 'Duration' => 185, 'Sign' => 1],
];

self::$client->executeQuery($tableSql);
Expand All @@ -87,9 +92,10 @@ public function testInsertUseColumns(string $tableSql): void
#[DataProvider('providerInsert')]
public function testInsertUseColumnsWithTypes(string $tableSql): void
{
$userId = ClickHouseVersion::get() >= 2508 ? 4324182021466249494 : '4324182021466249494';
$expectedData = [
['PageViews' => 5, 'UserID' => '4324182021466249494', 'Duration' => 146, 'Sign' => -1],
['PageViews' => 6, 'UserID' => '4324182021466249494', 'Duration' => 185, 'Sign' => 1],
['PageViews' => 5, 'UserID' => $userId, 'Duration' => 146, 'Sign' => -1],
['PageViews' => 6, 'UserID' => $userId, 'Duration' => 185, 'Sign' => 1],
];

self::$client->executeQuery($tableSql);
Expand Down Expand Up @@ -162,8 +168,11 @@ public function testInsertPayload(string $tableSql): void
new JsonEachRow(),
);

$data[0]['UserID'] = (string) $data[0]['UserID'];
$data[1]['UserID'] = (string) $data[1]['UserID'];
if (ClickHouseVersion::get() < 2508) {
$data[0]['UserID'] = (string) $data[0]['UserID'];
$data[1]['UserID'] = (string) $data[1]['UserID'];
}

self::assertSame($data, $output->data);
}

Expand Down Expand Up @@ -242,10 +251,11 @@ public function testInsertWithFormat(): void
new JsonEachRow(),
);

$userId = ClickHouseVersion::get() >= 2508 ? 4324182021466249494 : '4324182021466249494';
self::assertSame(
[
['PageViews' => 5, 'UserID' => '4324182021466249494', 'Duration' => 146, 'Sign' => -1],
['PageViews' => 6, 'UserID' => '4324182021466249494', 'Duration' => 185, 'Sign' => 1],
['PageViews' => 5, 'UserID' => $userId, 'Duration' => 146, 'Sign' => -1],
['PageViews' => 6, 'UserID' => $userId, 'Duration' => 185, 'Sign' => 1],
],
$output->data,
);
Expand Down
8 changes: 4 additions & 4 deletions tests/Client/SelectAsyncTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use SimPod\ClickHouseClient\Exception\ServerError;
use SimPod\ClickHouseClient\Format\JsonEachRow;
use SimPod\ClickHouseClient\Format\TabSeparated;
use SimPod\ClickHouseClient\Tests\ClickHouseVersion;
use SimPod\ClickHouseClient\Tests\TestCaseBase;
use SimPod\ClickHouseClient\Tests\WithClient;

Expand Down Expand Up @@ -47,10 +48,9 @@ public function testAsyncSelect(): void
*/
$jsonEachRowOutputs = Utils::all($promises)->wait();

$expectedData = [
['number' => '0'],
['number' => '1'],
];
$expectedData = ClickHouseVersion::get() >= 2508
? [['number' => 0], ['number' => 1]]
: [['number' => '0'], ['number' => '1']];

self::assertSame($expectedData, $jsonEachRowOutputs[0]->data);
self::assertSame($expectedData, $jsonEachRowOutputs[1]->data);
Expand Down
28 changes: 16 additions & 12 deletions tests/Client/SelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use SimPod\ClickHouseClient\Format\Null_;
use SimPod\ClickHouseClient\Format\TabSeparated;
use SimPod\ClickHouseClient\Settings\ArraySettingsProvider;
use SimPod\ClickHouseClient\Tests\ClickHouseVersion;
use SimPod\ClickHouseClient\Tests\TestCaseBase;
use SimPod\ClickHouseClient\Tests\WithClient;

Expand Down Expand Up @@ -60,11 +61,12 @@ public static function providerJson(): iterable
CLICKHOUSE,
];

$number = ClickHouseVersion::get() >= 2508
? [['number' => 0], ['number' => 1]]
: [['number' => '0'], ['number' => '1']];

yield [
[
['number' => '0'],
['number' => '1'],
],
$number,
<<<'CLICKHOUSE'
SELECT number FROM system.numbers LIMIT 2
CLICKHOUSE,
Expand Down Expand Up @@ -99,11 +101,12 @@ public static function providerJsonCompact(): iterable
CLICKHOUSE,
];

$number = ClickHouseVersion::get() >= 2508
? [[0], [1]]
: [['0'], ['1']];

yield [
[
['0'],
['1'],
],
$number,
<<<'CLICKHOUSE'
SELECT number FROM system.numbers LIMIT 2
CLICKHOUSE,
Expand Down Expand Up @@ -137,11 +140,12 @@ public static function providerJsonEachRow(): iterable
CLICKHOUSE,
];

$number = ClickHouseVersion::get() >= 2508
? [['number' => 0], ['number' => 1]]
: [['number' => '0'], ['number' => '1']];

yield [
[
['number' => '0'],
['number' => '1'],
],
$number,
<<<'CLICKHOUSE'
SELECT number FROM system.numbers LIMIT 2
CLICKHOUSE,
Expand Down
8 changes: 7 additions & 1 deletion tests/Snippet/DatabaseSizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ public function testRun(): void
$expectedSize = 150;
}

self::assertSame($expectedSize, DatabaseSize::run(self::$client));
$actualSize = DatabaseSize::run(self::$client);

if (ClickHouseVersion::get() >= 2508) {
self::assertGreaterThan(0, $actualSize);
} else {
self::assertSame($expectedSize, $actualSize);
}
}

public function tearDown(): void
Expand Down
Loading