Skip to content

Commit

Permalink
Merge pull request #15 from FriendsOfDoctrine/nullableTypes
Browse files Browse the repository at this point in the history
add support of Nullable types
close #14
  • Loading branch information
argayash authored Jul 25, 2018
2 parents 6c95593 + e1bea87 commit 3695bc4
Show file tree
Hide file tree
Showing 31 changed files with 596 additions and 269 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ $newTable = $toSchema->createTable('new_table');

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

//set primary key
$newTable->setPrimaryKey(['id']);
Expand Down
10 changes: 6 additions & 4 deletions src/ClickHouseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use function array_merge;
use function func_get_args;

/**
* ClickHouse implementation for the Connection interface.
Expand All @@ -36,7 +38,7 @@ class ClickHouseConnection implements Connection, PingableConnection, ServerInfo
/**
* Connection constructor
*
* @param array $params Array with connection params.
* @param mixed[] $params
*/
public function __construct(
array $params,
Expand Down Expand Up @@ -70,7 +72,7 @@ public function prepare($prepareString)
*/
public function query()
{
$args = \func_get_args();
$args = func_get_args();
$stmt = $this->prepare($args[0]);
$stmt->execute();

Expand Down Expand Up @@ -164,7 +166,7 @@ public function getServerVersion()
try {
return $this->smi2CHClient->getServerVersion();
} catch (TransportException $exception) {
return null;
return '';
}
}

Expand All @@ -173,6 +175,6 @@ public function getServerVersion()
*/
public function requiresQueryForServerVersion()
{
return true;
return true;
}
}
Loading

0 comments on commit 3695bc4

Please sign in to comment.