-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2017 Dmitry Bashkarev | ||
* @license https://github.com/bashkarev/PhpStorm/blob/master/LICENSE | ||
* @link https://github.com/bashkarev/PhpStorm#readme | ||
*/ | ||
|
||
namespace bashkarev\clickhouse\tests; | ||
|
||
use bashkarev\clickhouse\Schema; | ||
|
||
/** | ||
* @author Dmitry Bashkarev <[email protected]> | ||
*/ | ||
class SchemaTest extends DatabaseTestCase | ||
{ | ||
|
||
public function testTypes() | ||
{ | ||
$columns = $this->getConnection()->getSchema()->getTableSchema('types', true)->columns; | ||
|
||
$this->assertSame(Schema::TYPE_SMALLINT, $columns['UInt8']->type); | ||
$this->assertSame(Schema::TYPE_INTEGER, $columns['UInt16']->type); | ||
$this->assertSame(Schema::TYPE_INTEGER, $columns['UInt32']->type); | ||
$this->assertSame(Schema::TYPE_BIGINT, $columns['UInt64']->type); | ||
|
||
$this->assertSame(Schema::TYPE_SMALLINT, $columns['Int8']->type); | ||
$this->assertSame(Schema::TYPE_INTEGER, $columns['Int16']->type); | ||
$this->assertSame(Schema::TYPE_INTEGER, $columns['Int32']->type); | ||
$this->assertSame(Schema::TYPE_BIGINT, $columns['Int64']->type); | ||
|
||
$this->assertSame(Schema::TYPE_FLOAT, $columns['Float32']->type); | ||
$this->assertSame(Schema::TYPE_FLOAT, $columns['Float64']->type); | ||
|
||
$this->assertSame(Schema::TYPE_STRING, $columns['String']->type); | ||
$this->assertSame(Schema::TYPE_STRING, $columns['FixedString']->type); | ||
|
||
$this->assertSame(Schema::TYPE_DATETIME, $columns['DateTime']->type); | ||
$this->assertSame(Schema::TYPE_DATE, $columns['Date']->type); | ||
|
||
$this->assertSame(Schema::TYPE_STRING, $columns['Enum8']->type); | ||
$this->assertSame(Schema::TYPE_STRING, $columns['Enum16']->type); | ||
|
||
} | ||
|
||
public function testSize() | ||
{ | ||
$column = $this->getConnection()->getSchema()->getTableSchema('types', true)->columns['FixedString']; | ||
$this->assertSame(20, $column->size); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
DROP TABLE IF EXISTS `csv`; | ||
DROP TABLE IF EXISTS `customer`; | ||
DROP TABLE IF EXISTS `types`; | ||
|
||
|
||
CREATE TABLE csv (d Date, a String, b String) ENGINE = MergeTree(d, d, 8192); | ||
|
@@ -15,4 +16,23 @@ CREATE TABLE `customer` ( | |
|
||
INSERT INTO `customer` (id, email, name, address, status, profile_id) VALUES (1,'[email protected]', 'user1', 'address1', 1, 1); | ||
INSERT INTO `customer` (id, email, name, address, status) VALUES (2, '[email protected]', 'user2', 'address2', 1); | ||
INSERT INTO `customer` (id, email, name, address, status, profile_id) VALUES (3, '[email protected]', 'user3', 'address3', 2, 2); | ||
INSERT INTO `customer` (id, email, name, address, status, profile_id) VALUES (3, '[email protected]', 'user3', 'address3', 2, 2); | ||
|
||
CREATE TABLE `types` ( | ||
`UInt8` UInt8, | ||
`UInt16` UInt16, | ||
`UInt32` UInt32, | ||
`UInt64` UInt64, | ||
`Int8` Int8, | ||
`Int16` Int16, | ||
`Int32` Int32, | ||
`Int64` Int64, | ||
`Float32` Float32, | ||
`Float64` Float64, | ||
`String` String, | ||
`FixedString` FixedString(20), | ||
`DateTime` DateTime, | ||
`Date` Date, | ||
`Enum8` Enum8('hello' = 1, 'world' = 2), | ||
`Enum16` Enum8('hello' = 1, 'world' = 2) | ||
) ENGINE=Memory; |