Commit d1a3d400 by Carsten Brandt

added test case to acually create cols with virtual type

verify issue #3473
parent a55d9ba8
......@@ -114,6 +114,21 @@ class QueryBuilderTest extends DatabaseTestCase
}
}
public function testCreateTableColumnTypes()
{
$qb = $this->getQueryBuilder();
$columns = [];
$i = 0;
foreach ($this->columnTypes() as $item) {
list ($column, $expected) = $item;
if (strncmp($column, 'pk', 2) !== 0) {
$columns['col' . ++$i] = str_replace('CHECK (value', 'CHECK (col' . $i, $column);
}
}
$this->getConnection(false)->createCommand($qb->createTable('column_type_table', $columns))->execute();
$this->getConnection(false)->createCommand($qb->dropTable('column_type_table'))->execute();
}
public function conditionProvider()
{
$conditions = [
......
......@@ -22,13 +22,13 @@ class PostgreSQLQueryBuilderTest extends QueryBuilderTest
[Schema::TYPE_PK . '(8) CHECK (value > 5)', 'serial NOT NULL PRIMARY KEY CHECK (value > 5)'],
[Schema::TYPE_STRING, 'varchar(255)'],
[Schema::TYPE_STRING . '(32)', 'varchar(32)'],
[Schema::TYPE_STRING . ' CHECK (value LIKE "test%")', 'varchar(255) CHECK (value LIKE "test%")'],
[Schema::TYPE_STRING . '(32) CHECK (value LIKE "test%")', 'varchar(32) CHECK (value LIKE "test%")'],
[Schema::TYPE_STRING . ' CHECK (value LIKE \'test%\')', 'varchar(255) CHECK (value LIKE \'test%\')'],
[Schema::TYPE_STRING . '(32) CHECK (value LIKE \'test%\')', 'varchar(32) CHECK (value LIKE \'test%\')'],
[Schema::TYPE_STRING . ' NOT NULL', 'varchar(255) NOT NULL'],
[Schema::TYPE_TEXT, 'text'],
[Schema::TYPE_TEXT . '(255)', 'text'],
[Schema::TYPE_TEXT . ' CHECK (value LIKE "test%")', 'text CHECK (value LIKE "test%")'],
[Schema::TYPE_TEXT . '(255) CHECK (value LIKE "test%")', 'text CHECK (value LIKE "test%")'],
[Schema::TYPE_TEXT . ' CHECK (value LIKE \'test%\')', 'text CHECK (value LIKE \'test%\')'],
[Schema::TYPE_TEXT . '(255) CHECK (value LIKE \'test%\')', 'text CHECK (value LIKE \'test%\')'],
[Schema::TYPE_TEXT . ' NOT NULL', 'text NOT NULL'],
[Schema::TYPE_TEXT . '(255) NOT NULL', 'text NOT NULL'],
[Schema::TYPE_SMALLINT, 'smallint'],
......@@ -52,21 +52,22 @@ class PostgreSQLQueryBuilderTest extends QueryBuilderTest
[Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)', 'numeric(10,0) CHECK (value > 5.6)'],
[Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)', 'numeric(12,4) CHECK (value > 5.6)'],
[Schema::TYPE_DECIMAL . ' NOT NULL', 'numeric(10,0) NOT NULL'],
[Schema::TYPE_DATETIME, 'timestamp'],
[Schema::TYPE_DATETIME . " CHECK(value BETWEEN '2011-01-01' AND '2013-01-01')", "timestamp CHECK(value BETWEEN '2011-01-01' AND '2013-01-01')"],
[Schema::TYPE_DATETIME . ' NOT NULL', 'timestamp NOT NULL'],
[Schema::TYPE_TIMESTAMP, 'timestamp'],
[Schema::TYPE_TIMESTAMP . " CHECK(value BETWEEN '2011-01-01' AND '2013-01-01')", "timestamp CHECK(value BETWEEN '2011-01-01' AND '2013-01-01')"],
[Schema::TYPE_TIMESTAMP . ' NOT NULL', 'timestamp NOT NULL'],
[Schema::TYPE_TIME, 'time'],
[Schema::TYPE_TIME . " CHECK(value BETWEEN '12:00:00' AND '13:01:01')", "time CHECK(value BETWEEN '12:00:00' AND '13:01:01')"],
[Schema::TYPE_TIME . ' NOT NULL', 'time NOT NULL'],
[Schema::TYPE_DATETIME, 'timestamp(0)'],
[Schema::TYPE_DATETIME . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", "timestamp(0) CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"],
[Schema::TYPE_DATETIME . ' NOT NULL', 'timestamp(0) NOT NULL'],
[Schema::TYPE_TIMESTAMP, 'timestamp(0)'],
[Schema::TYPE_TIMESTAMP . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", "timestamp(0) CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"],
[Schema::TYPE_TIMESTAMP . ' NOT NULL', 'timestamp(0) NOT NULL'],
[Schema::TYPE_TIMESTAMP.'(4)', 'timestamp(4)'],
[Schema::TYPE_TIME, 'time(0)'],
[Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')", "time(0) CHECK (value BETWEEN '12:00:00' AND '13:01:01')"],
[Schema::TYPE_TIME . ' NOT NULL', 'time(0) NOT NULL'],
[Schema::TYPE_DATE, 'date'],
[Schema::TYPE_DATE . " CHECK(value BETWEEN '2011-01-01' AND '2013-01-01')", "date CHECK(value BETWEEN '2011-01-01' AND '2013-01-01')"],
[Schema::TYPE_DATE . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", "date CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"],
[Schema::TYPE_DATE . ' NOT NULL', 'date NOT NULL'],
[Schema::TYPE_BINARY, 'bytea'],
[Schema::TYPE_BOOLEAN, 'boolean'],
[Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'boolean NOT NULL DEFAULT 1'],
[Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT TRUE', 'boolean NOT NULL DEFAULT TRUE'],
[Schema::TYPE_MONEY, 'numeric(19,4)'],
[Schema::TYPE_MONEY . '(16,2)', 'numeric(16,2)'],
[Schema::TYPE_MONEY . ' CHECK (value > 0.0)', 'numeric(19,4) CHECK (value > 0.0)'],
......
......@@ -54,16 +54,16 @@ class SqliteQueryBuilderTest extends QueryBuilderTest
[Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)', 'decimal(12,4) CHECK (value > 5.6)'],
[Schema::TYPE_DECIMAL . ' NOT NULL', 'decimal(10,0) NOT NULL'],
[Schema::TYPE_DATETIME, 'datetime'],
[Schema::TYPE_DATETIME . " CHECK(value BETWEEN '2011-01-01' AND '2013-01-01')", "datetime CHECK(value BETWEEN '2011-01-01' AND '2013-01-01')"],
[Schema::TYPE_DATETIME . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", "datetime CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"],
[Schema::TYPE_DATETIME . ' NOT NULL', 'datetime NOT NULL'],
[Schema::TYPE_TIMESTAMP, 'timestamp'],
[Schema::TYPE_TIMESTAMP . " CHECK(value BETWEEN '2011-01-01' AND '2013-01-01')", "timestamp CHECK(value BETWEEN '2011-01-01' AND '2013-01-01')"],
[Schema::TYPE_TIMESTAMP . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", "timestamp CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"],
[Schema::TYPE_TIMESTAMP . ' NOT NULL', 'timestamp NOT NULL'],
[Schema::TYPE_TIME, 'time'],
[Schema::TYPE_TIME . " CHECK(value BETWEEN '12:00:00' AND '13:01:01')", "time CHECK(value BETWEEN '12:00:00' AND '13:01:01')"],
[Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')", "time CHECK (value BETWEEN '12:00:00' AND '13:01:01')"],
[Schema::TYPE_TIME . ' NOT NULL', 'time NOT NULL'],
[Schema::TYPE_DATE, 'date'],
[Schema::TYPE_DATE . " CHECK(value BETWEEN '2011-01-01' AND '2013-01-01')", "date CHECK(value BETWEEN '2011-01-01' AND '2013-01-01')"],
[Schema::TYPE_DATE . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", "date CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"],
[Schema::TYPE_DATE . ' NOT NULL', 'date NOT NULL'],
[Schema::TYPE_BINARY, 'blob'],
[Schema::TYPE_BOOLEAN, 'boolean'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment