Skip to content

Commit be82c70

Browse files
committed
fix BigInt type declaration; add custom BigInt type for ClickHouse
1 parent 48c8577 commit be82c70

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

src/ClickHousePlatform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function getIntegerTypeDeclarationSQL(array $columnDef)
5656
*/
5757
public function getBigIntTypeDeclarationSQL(array $columnDef)
5858
{
59-
return $this->_getCommonIntegerTypeDeclarationSQL($columnDef) . 'Int64';
59+
return 'String';
6060
}
6161

6262
/**

src/Types/BigIntType.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/*
3+
* This file is part of the FODDBALClickHouse package -- Doctrine DBAL library
4+
* for ClickHouse (a column-oriented DBMS for OLAP <https://clickhouse.yandex/>)
5+
*
6+
* (c) FriendsOfDoctrine <https://github.com/FriendsOfDoctrine/>.
7+
*
8+
* For the full copyright and license inflormation, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace FOD\DBALClickHouse\Types;
13+
14+
use Doctrine\DBAL\Platforms\AbstractPlatform;
15+
16+
/**
17+
* BigInt Type
18+
*
19+
* @author Mochalygin <[email protected]>
20+
*/
21+
class BigIntType extends \Doctrine\DBAL\Types\BigIntType
22+
{
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function getBindingType()
27+
{
28+
return \PDO::PARAM_INT;
29+
}
30+
31+
/**
32+
* {@inheritdoc}
33+
*/
34+
public function convertToDatabaseValue($value, AbstractPlatform $platform)
35+
{
36+
return (int)$value;
37+
}
38+
39+
/**
40+
* {@inheritdoc}
41+
*/
42+
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
43+
{
44+
return (empty($fieldDeclaration['unsigned']) ? '' : 'U') . 'Int64';
45+
}
46+
}

0 commit comments

Comments
 (0)