Skip to content

Commit 3695bc4

Browse files
authored
Merge pull request #15 from FriendsOfDoctrine/nullableTypes
add support of Nullable types close #14
2 parents 6c95593 + e1bea87 commit 3695bc4

31 files changed

+596
-269
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,12 @@ $newTable = $toSchema->createTable('new_table');
7878

7979
// add columns
8080
$newTable->addColumn('id', 'integer', ['unsigned' => true]);
81-
$newTable->addColumn('payload', 'string');
81+
$newTable->addColumn('payload', 'string', ['notnull' => false]);
82+
// *option 'notnull' in false mode allows you to insert NULL into the column;
83+
// in this case, the column will be represented in the ClickHouse as Nullable(String)
8284
$newTable->addColumn('hash', 'string', ['length' => 32, 'fixed' => true]);
83-
// *option 'fixed' sets the fixed length of a string column as specified; if specified, the type of the column is FixedString
85+
// *option 'fixed' sets the fixed length of a string column as specified;
86+
// if specified, the type of the column is FixedString
8487

8588
//set primary key
8689
$newTable->setPrimaryKey(['id']);

src/ClickHouseConnection.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
2222
use Doctrine\DBAL\ParameterType;
2323
use Doctrine\DBAL\Platforms\AbstractPlatform;
24+
use function array_merge;
25+
use function func_get_args;
2426

2527
/**
2628
* ClickHouse implementation for the Connection interface.
@@ -36,7 +38,7 @@ class ClickHouseConnection implements Connection, PingableConnection, ServerInfo
3638
/**
3739
* Connection constructor
3840
*
39-
* @param array $params Array with connection params.
41+
* @param mixed[] $params
4042
*/
4143
public function __construct(
4244
array $params,
@@ -70,7 +72,7 @@ public function prepare($prepareString)
7072
*/
7173
public function query()
7274
{
73-
$args = \func_get_args();
75+
$args = func_get_args();
7476
$stmt = $this->prepare($args[0]);
7577
$stmt->execute();
7678

@@ -164,7 +166,7 @@ public function getServerVersion()
164166
try {
165167
return $this->smi2CHClient->getServerVersion();
166168
} catch (TransportException $exception) {
167-
return null;
169+
return '';
168170
}
169171
}
170172

@@ -173,6 +175,6 @@ public function getServerVersion()
173175
*/
174176
public function requiresQueryForServerVersion()
175177
{
176-
return true;
178+
return true;
177179
}
178180
}

0 commit comments

Comments
 (0)