Browse Source

Adds `char` datatype to framework

tags/2.0.8
Chris Harris 9 years ago
parent
commit
eaeb926768
  1. 5
      framework/CHANGELOG.md
  2. 2
      framework/db/ColumnSchema.php
  3. 1
      framework/db/QueryBuilder.php
  4. 1
      framework/db/Schema.php
  5. 12
      framework/db/SchemaBuilderTrait.php
  6. 1
      framework/db/cubrid/QueryBuilder.php
  7. 4
      framework/db/cubrid/Schema.php
  8. 1
      framework/db/mssql/QueryBuilder.php
  9. 4
      framework/db/mssql/Schema.php
  10. 1
      framework/db/mysql/QueryBuilder.php
  11. 2
      framework/db/mysql/Schema.php
  12. 1
      framework/db/oci/QueryBuilder.php
  13. 1
      framework/db/pgsql/QueryBuilder.php
  14. 5
      framework/db/pgsql/Schema.php
  15. 1
      framework/db/sqlite/QueryBuilder.php
  16. 2
      framework/db/sqlite/Schema.php
  17. 399
      tests/framework/db/QueryBuilderTest.php
  18. 26
      tests/framework/db/SchemaTest.php
  19. 397
      tests/framework/db/cubrid/CubridQueryBuilderTest.php
  20. 395
      tests/framework/db/oci/OracleQueryBuilderTest.php
  21. 391
      tests/framework/db/pgsql/PostgreSQLQueryBuilderTest.php
  22. 397
      tests/framework/db/sqlite/SqliteQueryBuilderTest.php

5
framework/CHANGELOG.md

@ -5,10 +5,15 @@ Yii Framework 2 Change Log
-----------------------
- Bug #9851: Fixed partial commit / rollback in nested transactions (sammousa)
- Bug #10889: Allows `unsigned()` modifier in primary key column definitions
- Enh #10451: Check of existence of `$_SERVER` in `\yii\web\Request` before using it (quantum13)
- Enh #10610: Added `BaseUrl::$urlManager` to be able to set URL manager used for creating URLs (samdark)
- Enh #10764: `yii\helpers\Html::tag()` and `::beginTag()` return content without any HTML when the `$tag` attribute is `false` or `null` (pana1990)
- Chg: HTMLPurifier dependency updated to ~4.7.0 (samdark)
- Chg: Inverts responsibility of database specific column schema builder classes (df2)
- Enh #9562: Adds `char` datatype to framework (df2)
- Enh #9340: Adds `after()` and `first()` column schema builder modifiers (df2)
- Enh: `__toString()` of column schema builder now follows column type rules (df2)
2.0.7 February 14, 2016
-----------------------

2
framework/db/ColumnSchema.php

@ -27,7 +27,7 @@ class ColumnSchema extends Object
public $allowNull;
/**
* @var string abstract type of this column. Possible abstract types include:
* string, text, boolean, smallint, integer, bigint, float, decimal, datetime,
* char, string, text, boolean, smallint, integer, bigint, float, decimal, datetime,
* timestamp, time, date, binary, and money.
*/
public $type;

1
framework/db/QueryBuilder.php

@ -576,6 +576,7 @@ class QueryBuilder extends \yii\base\Object
*
* - `pk`: an auto-incremental primary key type, will be converted into "int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY"
* - `bigpk`: an auto-incremental primary key type, will be converted into "bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY"
* - `char`: char type, will be converted into "char(1)"
* - `string`: string type, will be converted into "varchar(255)"
* - `text`: a long string type, will be converted into "text"
* - `smallint`: a small integer type, will be converted into "smallint(6)"

1
framework/db/Schema.php

@ -42,6 +42,7 @@ abstract class Schema extends Object
*/
const TYPE_PK = 'pk';
const TYPE_BIGPK = 'bigpk';
const TYPE_CHAR = 'char';
const TYPE_STRING = 'string';
const TYPE_TEXT = 'text';
const TYPE_SMALLINT = 'smallint';

12
framework/db/SchemaBuilderTrait.php

@ -64,6 +64,18 @@ trait SchemaBuilderTrait
}
/**
* Creates a char column.
* @param integer $length column size definition i.e. the maximum string length.
* This parameter will be ignored if not supported by the DBMS.
* @return ColumnSchemaBuilder the column instance which can be further customized.
* @since 2.0.7
*/
public function char($length = null)
{
return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_CHAR, $length);
}
/**
* Creates a string column.
* @param integer $length column size definition i.e. the maximum string length.
* This parameter will be ignored if not supported by the DBMS.

1
framework/db/cubrid/QueryBuilder.php

@ -23,6 +23,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
public $typeMap = [
Schema::TYPE_PK => 'int NOT NULL AUTO_INCREMENT PRIMARY KEY',
Schema::TYPE_BIGPK => 'bigint NOT NULL AUTO_INCREMENT PRIMARY KEY',
Schema::TYPE_CHAR => 'char(1)',
Schema::TYPE_STRING => 'varchar(255)',
Schema::TYPE_TEXT => 'varchar',
Schema::TYPE_SMALLINT => 'smallint',

4
framework/db/cubrid/Schema.php

@ -45,10 +45,10 @@ class Schema extends \yii\db\Schema
'timestamp' => self::TYPE_TIMESTAMP,
'datetime' => self::TYPE_DATETIME,
// String data types
'char' => self::TYPE_STRING,
'char' => self::TYPE_CHAR,
'varchar' => self::TYPE_STRING,
'char varying' => self::TYPE_STRING,
'nchar' => self::TYPE_STRING,
'nchar' => self::TYPE_CHAR,
'nchar varying' => self::TYPE_STRING,
'string' => self::TYPE_STRING,
// BLOB/CLOB data types

1
framework/db/mssql/QueryBuilder.php

@ -24,6 +24,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
public $typeMap = [
Schema::TYPE_PK => 'int IDENTITY PRIMARY KEY',
Schema::TYPE_BIGPK => 'bigint IDENTITY PRIMARY KEY',
Schema::TYPE_CHAR => 'char(1)',
Schema::TYPE_STRING => 'varchar(255)',
Schema::TYPE_TEXT => 'text',
Schema::TYPE_SMALLINT => 'smallint',

4
framework/db/mssql/Schema.php

@ -47,11 +47,11 @@ class Schema extends \yii\db\Schema
'datetime' => self::TYPE_DATETIME,
'time' => self::TYPE_TIME,
// character strings
'char' => self::TYPE_STRING,
'char' => self::TYPE_CHAR,
'varchar' => self::TYPE_STRING,
'text' => self::TYPE_TEXT,
// unicode character strings
'nchar' => self::TYPE_STRING,
'nchar' => self::TYPE_CHAR,
'nvarchar' => self::TYPE_STRING,
'ntext' => self::TYPE_TEXT,
// binary strings

1
framework/db/mysql/QueryBuilder.php

@ -25,6 +25,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
public $typeMap = [
Schema::TYPE_PK => 'int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY',
Schema::TYPE_BIGPK => 'bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY',
Schema::TYPE_CHAR => 'char(1)',
Schema::TYPE_STRING => 'varchar(255)',
Schema::TYPE_TEXT => 'text',
Schema::TYPE_SMALLINT => 'smallint(6)',

2
framework/db/mysql/Schema.php

@ -43,7 +43,7 @@ class Schema extends \yii\db\Schema
'text' => self::TYPE_TEXT,
'varchar' => self::TYPE_STRING,
'string' => self::TYPE_STRING,
'char' => self::TYPE_STRING,
'char' => self::TYPE_CHAR,
'datetime' => self::TYPE_DATETIME,
'year' => self::TYPE_DATE,
'date' => self::TYPE_DATE,

1
framework/db/oci/QueryBuilder.php

@ -26,6 +26,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
public $typeMap = [
Schema::TYPE_PK => 'NUMBER(10) NOT NULL PRIMARY KEY',
Schema::TYPE_BIGPK => 'NUMBER(20) NOT NULL PRIMARY KEY',
Schema::TYPE_CHAR => 'CHAR(1)',
Schema::TYPE_STRING => 'VARCHAR2(255)',
Schema::TYPE_TEXT => 'CLOB',
Schema::TYPE_SMALLINT => 'NUMBER(5)',

1
framework/db/pgsql/QueryBuilder.php

@ -49,6 +49,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
public $typeMap = [
Schema::TYPE_PK => 'serial NOT NULL PRIMARY KEY',
Schema::TYPE_BIGPK => 'bigserial NOT NULL PRIMARY KEY',
Schema::TYPE_CHAR => 'char(1)',
Schema::TYPE_STRING => 'varchar(255)',
Schema::TYPE_TEXT => 'text',
Schema::TYPE_SMALLINT => 'smallint',

5
framework/db/pgsql/Schema.php

@ -45,8 +45,9 @@ class Schema extends \yii\db\Schema
'polygon' => self::TYPE_STRING,
'path' => self::TYPE_STRING,
'character' => self::TYPE_STRING,
'char' => self::TYPE_STRING,
'character' => self::TYPE_CHAR,
'char' => self::TYPE_CHAR,
'bpchar' => self::TYPE_CHAR,
'character varying' => self::TYPE_STRING,
'varchar' => self::TYPE_STRING,
'text' => self::TYPE_TEXT,

1
framework/db/sqlite/QueryBuilder.php

@ -28,6 +28,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
public $typeMap = [
Schema::TYPE_PK => 'integer PRIMARY KEY AUTOINCREMENT NOT NULL',
Schema::TYPE_BIGPK => 'integer PRIMARY KEY AUTOINCREMENT NOT NULL',
Schema::TYPE_CHAR => 'char(1)',
Schema::TYPE_STRING => 'varchar(255)',
Schema::TYPE_TEXT => 'text',
Schema::TYPE_SMALLINT => 'smallint',

2
framework/db/sqlite/Schema.php

@ -48,7 +48,7 @@ class Schema extends \yii\db\Schema
'text' => self::TYPE_TEXT,
'varchar' => self::TYPE_STRING,
'string' => self::TYPE_STRING,
'char' => self::TYPE_STRING,
'char' => self::TYPE_CHAR,
'blob' => self::TYPE_BINARY,
'datetime' => self::TYPE_DATETIME,
'year' => self::TYPE_DATE,

399
tests/framework/db/QueryBuilderTest.php

@ -83,68 +83,343 @@ class QueryBuilderTest extends DatabaseTestCase
public function columnTypes()
{
return [
[Schema::TYPE_PK, $this->primaryKey(), 'int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY'],
[Schema::TYPE_PK . '(8)', $this->primaryKey(8), 'int(8) NOT NULL AUTO_INCREMENT PRIMARY KEY'],
[Schema::TYPE_PK . ' CHECK (value > 5)', $this->primaryKey()->check('value > 5'), 'int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY CHECK (value > 5)'],
[Schema::TYPE_PK . '(8) CHECK (value > 5)', $this->primaryKey(8)->check('value > 5'), 'int(8) NOT NULL AUTO_INCREMENT PRIMARY KEY CHECK (value > 5)'],
[Schema::TYPE_STRING, $this->string(), 'varchar(255)'],
[Schema::TYPE_STRING . '(32)', $this->string(32), 'varchar(32)'],
[Schema::TYPE_STRING . ' CHECK (value LIKE "test%")', $this->string()->check('value LIKE "test%"'), 'varchar(255) CHECK (value LIKE "test%")'],
[Schema::TYPE_STRING . '(32) CHECK (value LIKE "test%")', $this->string(32)->check('value LIKE "test%"'), 'varchar(32) CHECK (value LIKE "test%")'],
[Schema::TYPE_STRING . ' NOT NULL', $this->string()->notNull(), 'varchar(255) NOT NULL'],
[Schema::TYPE_TEXT, $this->text(), 'text'],
[Schema::TYPE_TEXT . '(255)', $this->text(), 'text', Schema::TYPE_TEXT],
[Schema::TYPE_TEXT . ' CHECK (value LIKE "test%")', $this->text()->check('value LIKE "test%"'), 'text CHECK (value LIKE "test%")'],
[Schema::TYPE_TEXT . '(255) CHECK (value LIKE "test%")', $this->text()->check('value LIKE "test%"'), 'text CHECK (value LIKE "test%")', Schema::TYPE_TEXT . ' CHECK (value LIKE "test%")'],
[Schema::TYPE_TEXT . ' NOT NULL', $this->text()->notNull(), 'text NOT NULL'],
[Schema::TYPE_TEXT . '(255) NOT NULL', $this->text()->notNull(), 'text NOT NULL', Schema::TYPE_TEXT . ' NOT NULL'],
[Schema::TYPE_SMALLINT, $this->smallInteger(), 'smallint(6)'],
[Schema::TYPE_SMALLINT . '(8)', $this->smallInteger(8), 'smallint(8)'],
[Schema::TYPE_INTEGER, $this->integer(), 'int(11)'],
[Schema::TYPE_INTEGER . '(8)', $this->integer(8), 'int(8)'],
[Schema::TYPE_INTEGER . ' CHECK (value > 5)', $this->integer()->check('value > 5'), 'int(11) CHECK (value > 5)'],
[Schema::TYPE_INTEGER . '(8) CHECK (value > 5)', $this->integer(8)->check('value > 5'), 'int(8) CHECK (value > 5)'],
[Schema::TYPE_INTEGER . ' NOT NULL', $this->integer()->notNull(), 'int(11) NOT NULL'],
[Schema::TYPE_BIGINT, $this->bigInteger(), 'bigint(20)'],
[Schema::TYPE_BIGINT . '(8)', $this->bigInteger(8), 'bigint(8)'],
[Schema::TYPE_BIGINT . ' CHECK (value > 5)', $this->bigInteger()->check('value > 5'), 'bigint(20) CHECK (value > 5)'],
[Schema::TYPE_BIGINT . '(8) CHECK (value > 5)', $this->bigInteger(8)->check('value > 5'), 'bigint(8) CHECK (value > 5)'],
[Schema::TYPE_BIGINT . ' NOT NULL', $this->bigInteger()->notNull(), 'bigint(20) NOT NULL'],
[Schema::TYPE_FLOAT, $this->float(), 'float'],
[Schema::TYPE_FLOAT . '(16)', $this->float(16), 'float'],
[Schema::TYPE_FLOAT . ' CHECK (value > 5.6)', $this->float()->check('value > 5.6'), 'float CHECK (value > 5.6)'],
[Schema::TYPE_FLOAT . '(16) CHECK (value > 5.6)', $this->float(16)->check('value > 5.6'), 'float CHECK (value > 5.6)'],
[Schema::TYPE_FLOAT . ' NOT NULL', $this->float()->notNull(), 'float NOT NULL'],
[Schema::TYPE_DOUBLE, $this->double(), 'double'],
[Schema::TYPE_DOUBLE . '(16)', $this->double(16), 'double'],
[Schema::TYPE_DOUBLE . ' CHECK (value > 5.6)', $this->double()->check('value > 5.6'), 'double CHECK (value > 5.6)'],
[Schema::TYPE_DOUBLE . '(16) CHECK (value > 5.6)', $this->double(16)->check('value > 5.6'), 'double CHECK (value > 5.6)'],
[Schema::TYPE_DOUBLE . ' NOT NULL', $this->double()->notNull(), 'double NOT NULL'],
[Schema::TYPE_DECIMAL, $this->decimal(), 'decimal(10,0)'],
[Schema::TYPE_DECIMAL . '(12,4)', $this->decimal(12, 4), 'decimal(12,4)'],
[Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)', $this->decimal()->check('value > 5.6'), 'decimal(10,0) CHECK (value > 5.6)'],
[Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)', $this->decimal(12, 4)->check('value > 5.6'), 'decimal(12,4) CHECK (value > 5.6)'],
[Schema::TYPE_DECIMAL . ' NOT NULL', $this->decimal()->notNull(), 'decimal(10,0) NOT NULL'],
[Schema::TYPE_DATETIME, $this->dateTime(), 'datetime'],
[Schema::TYPE_DATETIME . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", $this->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', $this->dateTime()->notNull(), 'datetime NOT NULL'],
[Schema::TYPE_TIMESTAMP, $this->timestamp(), 'timestamp'],
[Schema::TYPE_TIMESTAMP . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", $this->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', $this->timestamp()->notNull(), 'timestamp NOT NULL'],
[Schema::TYPE_TIME, $this->time(), 'time'],
[Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')", $this->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', $this->time()->notNull(), 'time NOT NULL'],
[Schema::TYPE_DATE, $this->date(), 'date'],
[Schema::TYPE_DATE . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", $this->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', $this->date()->notNull(), 'date NOT NULL'],
[Schema::TYPE_BINARY, $this->binary(), 'blob'],
[Schema::TYPE_BOOLEAN, $this->boolean(), 'tinyint(1)'],
[Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', $this->boolean()->notNull()->defaultValue(1), 'tinyint(1) NOT NULL DEFAULT 1'],
[Schema::TYPE_MONEY, $this->money(), 'decimal(19,4)'],
[Schema::TYPE_MONEY . '(16,2)', $this->money(16, 2), 'decimal(16,2)'],
[Schema::TYPE_MONEY . ' CHECK (value > 0.0)', $this->money()->check('value > 0.0'), 'decimal(19,4) CHECK (value > 0.0)'],
[Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)', $this->money(16, 2)->check('value > 0.0'), 'decimal(16,2) CHECK (value > 0.0)'],
[Schema::TYPE_MONEY . ' NOT NULL', $this->money()->notNull(), 'decimal(19,4) NOT NULL'],
[
Schema::TYPE_PK,
$this->primaryKey(),
'int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY'
],
[
Schema::TYPE_PK . '(8)',
$this->primaryKey(8),
'int(8) NOT NULL AUTO_INCREMENT PRIMARY KEY'
],
[
Schema::TYPE_PK . ' CHECK (value > 5)',
$this->primaryKey()->check('value > 5'),
'int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY CHECK (value > 5)'
],
[
Schema::TYPE_PK . '(8) CHECK (value > 5)',
$this->primaryKey(8)->check('value > 5'),
'int(8) NOT NULL AUTO_INCREMENT PRIMARY KEY CHECK (value > 5)'
],
[
Schema::TYPE_CHAR,
$this->char(),
'char(1)'
],
[
Schema::TYPE_CHAR . '(6)',
$this->char(6),
'char(6)'
],
[
Schema::TYPE_CHAR . ' CHECK (value LIKE "test%")',
$this->char()->check('value LIKE "test%"'),
'char(1) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_CHAR . '(6) CHECK (value LIKE "test%")',
$this->char(6)->check('value LIKE "test%"'),
'char(6) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_CHAR . ' NOT NULL',
$this->char()->notNull(),
'char(1) NOT NULL'
],
[
Schema::TYPE_STRING,
$this->string(),
'varchar(255)'
],
[
Schema::TYPE_STRING . '(32)',
$this->string(32),
'varchar(32)'
],
[
Schema::TYPE_STRING . ' CHECK (value LIKE "test%")',
$this->string()->check('value LIKE "test%"'),
'varchar(255) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_STRING . '(32) CHECK (value LIKE "test%")',
$this->string(32)->check('value LIKE "test%"'),
'varchar(32) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_STRING . ' NOT NULL',
$this->string()->notNull(),
'varchar(255) NOT NULL'
],
[
Schema::TYPE_TEXT,
$this->text(),
'text'
],
[
Schema::TYPE_TEXT . '(255)',
$this->text(),
'text',
Schema::TYPE_TEXT
],
[
Schema::TYPE_TEXT . ' CHECK (value LIKE "test%")',
$this->text()->check('value LIKE "test%"'),
'text CHECK (value LIKE "test%")'
],
[
Schema::TYPE_TEXT . '(255) CHECK (value LIKE "test%")',
$this->text()->check('value LIKE "test%"'),
'text CHECK (value LIKE "test%")',
],
[
Schema::TYPE_TEXT . ' NOT NULL',
$this->text()->notNull(),
'text NOT NULL'
],
[
Schema::TYPE_TEXT . '(255) NOT NULL',
$this->text()->notNull(),
'text NOT NULL',
],
[
Schema::TYPE_SMALLINT,
$this->smallInteger(),
'smallint(6)'
],
[
Schema::TYPE_SMALLINT . '(8)',
$this->smallInteger(8),
'smallint(8)'
],
[
Schema::TYPE_INTEGER,
$this->integer(),
'int(11)'
],
[
Schema::TYPE_INTEGER . '(8)',
$this->integer(8),
'int(8)'
],
[
Schema::TYPE_INTEGER . ' CHECK (value > 5)',
$this->integer()->check('value > 5'),
'int(11) CHECK (value > 5)'
],
[
Schema::TYPE_INTEGER . '(8) CHECK (value > 5)',
$this->integer(8)->check('value > 5'),
'int(8) CHECK (value > 5)'
],
[
Schema::TYPE_INTEGER . ' NOT NULL',
$this->integer()->notNull(),
'int(11) NOT NULL'
],
[
Schema::TYPE_BIGINT,
$this->bigInteger(),
'bigint(20)'
],
[
Schema::TYPE_BIGINT . '(8)',
$this->bigInteger(8),
'bigint(8)'
],
[
Schema::TYPE_BIGINT . ' CHECK (value > 5)',
$this->bigInteger()->check('value > 5'),
'bigint(20) CHECK (value > 5)'
],
[
Schema::TYPE_BIGINT . '(8) CHECK (value > 5)',
$this->bigInteger(8)->check('value > 5'),
'bigint(8) CHECK (value > 5)'
],
[
Schema::TYPE_BIGINT . ' NOT NULL',
$this->bigInteger()->notNull(),
'bigint(20) NOT NULL'
],
[
Schema::TYPE_FLOAT,
$this->float(),
'float'
],
[
Schema::TYPE_FLOAT . '(16)',
$this->float(16),
'float'
],
[
Schema::TYPE_FLOAT . ' CHECK (value > 5.6)',
$this->float()->check('value > 5.6'),
'float CHECK (value > 5.6)'
],
[
Schema::TYPE_FLOAT . '(16) CHECK (value > 5.6)',
$this->float(16)->check('value > 5.6'),
'float CHECK (value > 5.6)'
],
[
Schema::TYPE_FLOAT . ' NOT NULL',
$this->float()->notNull(),
'float NOT NULL'
],
[
Schema::TYPE_DOUBLE,
$this->double(),
'double'
],
[
Schema::TYPE_DOUBLE . '(16)',
$this->double(16),
'double'
],
[
Schema::TYPE_DOUBLE . ' CHECK (value > 5.6)',
$this->double()->check('value > 5.6'),
'double CHECK (value > 5.6)'
],
[
Schema::TYPE_DOUBLE . '(16) CHECK (value > 5.6)',
$this->double(16)->check('value > 5.6'),
'double CHECK (value > 5.6)'
],
[
Schema::TYPE_DOUBLE . ' NOT NULL',
$this->double()->notNull(),
'double NOT NULL'
],
[
Schema::TYPE_DECIMAL,
$this->decimal(),
'decimal(10,0)'
],
[
Schema::TYPE_DECIMAL . '(12,4)',
$this->decimal(12, 4),
'decimal(12,4)'
],
[
Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)',
$this->decimal()->check('value > 5.6'),
'decimal(10,0) CHECK (value > 5.6)'
],
[
Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)',
$this->decimal(12, 4)->check('value > 5.6'),
'decimal(12,4) CHECK (value > 5.6)'
],
[
Schema::TYPE_DECIMAL . ' NOT NULL',
$this->decimal()->notNull(),
'decimal(10,0) NOT NULL'
],
[
Schema::TYPE_DATETIME,
$this->dateTime(),
'datetime'
],
[
Schema::TYPE_DATETIME . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')",
$this->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',
$this->dateTime()->notNull(),
'datetime NOT NULL'
],
[
Schema::TYPE_TIMESTAMP,
$this->timestamp(),
'timestamp'
],
[
Schema::TYPE_TIMESTAMP . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')",
$this->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',
$this->timestamp()->notNull(),
'timestamp NOT NULL'
],
[
Schema::TYPE_TIME,
$this->time(),
'time'
],
[
Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')",
$this->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',
$this->time()->notNull(),
'time NOT NULL'
],
[
Schema::TYPE_DATE,
$this->date(),
'date'
],
[
Schema::TYPE_DATE . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')",
$this->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',
$this->date()->notNull(),
'date NOT NULL'
],
[
Schema::TYPE_BINARY,
$this->binary(),
'blob'
],
[
Schema::TYPE_BOOLEAN,
$this->boolean(),
'tinyint(1)'
],
[
Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1',
$this->boolean()->notNull()->defaultValue(1),
'tinyint(1) NOT NULL DEFAULT 1'
],
[
Schema::TYPE_MONEY,
$this->money(),
'decimal(19,4)'
],
[
Schema::TYPE_MONEY . '(16,2)',
$this->money(16, 2),
'decimal(16,2)'
],
[
Schema::TYPE_MONEY . ' CHECK (value > 0.0)',
$this->money()->check('value > 0.0'),
'decimal(19,4) CHECK (value > 0.0)'
],
[
Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)',
$this->money(16, 2)->check('value > 0.0'),
'decimal(16,2) CHECK (value > 0.0)'
],
[
Schema::TYPE_MONEY . ' NOT NULL',
$this->money()->notNull(),
'decimal(19,4) NOT NULL'
],
];
}

26
tests/framework/db/SchemaTest.php

@ -161,7 +161,7 @@ class SchemaTest extends DatabaseTestCase
'defaultValue' => 1,
],
'char_col' => [
'type' => 'string',
'type' => 'char',
'dbType' => 'char(100)',
'phpType' => 'string',
'allowNull' => false,
@ -333,20 +333,20 @@ class SchemaTest extends DatabaseTestCase
foreach($table->columns as $name => $column) {
$expected = $columns[$name];
$this->assertSame($expected['dbType'], $column->dbType, "dbType of colum $name does not match. type is $column->type, dbType is $column->dbType.");
$this->assertSame($expected['phpType'], $column->phpType, "phpType of colum $name does not match. type is $column->type, dbType is $column->dbType.");
$this->assertSame($expected['type'], $column->type, "type of colum $name does not match.");
$this->assertSame($expected['allowNull'], $column->allowNull, "allowNull of colum $name does not match.");
$this->assertSame($expected['autoIncrement'], $column->autoIncrement, "autoIncrement of colum $name does not match.");
$this->assertSame($expected['enumValues'], $column->enumValues, "enumValues of colum $name does not match.");
$this->assertSame($expected['size'], $column->size, "size of colum $name does not match.");
$this->assertSame($expected['precision'], $column->precision, "precision of colum $name does not match.");
$this->assertSame($expected['scale'], $column->scale, "scale of colum $name does not match.");
$this->assertSame($expected['dbType'], $column->dbType, "dbType of column $name does not match. type is $column->type, dbType is $column->dbType.");
$this->assertSame($expected['phpType'], $column->phpType, "phpType of column $name does not match. type is $column->type, dbType is $column->dbType.");
$this->assertSame($expected['type'], $column->type, "type of column $name does not match.");
$this->assertSame($expected['allowNull'], $column->allowNull, "allowNull of column $name does not match.");
$this->assertSame($expected['autoIncrement'], $column->autoIncrement, "autoIncrement of column $name does not match.");
$this->assertSame($expected['enumValues'], $column->enumValues, "enumValues of column $name does not match.");
$this->assertSame($expected['size'], $column->size, "size of column $name does not match.");
$this->assertSame($expected['precision'], $column->precision, "precision of column $name does not match.");
$this->assertSame($expected['scale'], $column->scale, "scale of column $name does not match.");
if (is_object($expected['defaultValue'])) {
$this->assertTrue(is_object($column->defaultValue), "defaultValue of colum $name is expected to be an object but it is not.");
$this->assertEquals((string) $expected['defaultValue'], (string) $column->defaultValue, "defaultValue of colum $name does not match.");
$this->assertTrue(is_object($column->defaultValue), "defaultValue of column $name is expected to be an object but it is not.");
$this->assertEquals((string) $expected['defaultValue'], (string) $column->defaultValue, "defaultValue of column $name does not match.");
} else {
$this->assertSame($expected['defaultValue'], $column->defaultValue, "defaultValue of colum $name does not match.");
$this->assertSame($expected['defaultValue'], $column->defaultValue, "defaultValue of column $name does not match.");
}
}
}

397
tests/framework/db/cubrid/CubridQueryBuilderTest.php

@ -20,68 +20,341 @@ class CubridQueryBuilderTest extends QueryBuilderTest
public function columnTypes()
{
return [
[Schema::TYPE_PK, $this->primaryKey(), 'int NOT NULL AUTO_INCREMENT PRIMARY KEY'],
[Schema::TYPE_PK . '(8)', $this->primaryKey(8), 'int NOT NULL AUTO_INCREMENT PRIMARY KEY'],
[Schema::TYPE_PK . ' CHECK (value > 5)', $this->primaryKey()->check('value > 5'), 'int NOT NULL AUTO_INCREMENT PRIMARY KEY CHECK (value > 5)'],
[Schema::TYPE_PK . '(8) CHECK (value > 5)', $this->primaryKey(8)->check('value > 5'), 'int NOT NULL AUTO_INCREMENT PRIMARY KEY CHECK (value > 5)'],
[Schema::TYPE_STRING, $this->string(), 'varchar(255)'],
[Schema::TYPE_STRING . '(32)', $this->string(32), 'varchar(32)'],
[Schema::TYPE_STRING . ' CHECK (value LIKE "test%")', $this->string()->check('value LIKE "test%"'), 'varchar(255) CHECK (value LIKE "test%")'],
[Schema::TYPE_STRING . '(32) CHECK (value LIKE "test%")', $this->string(32)->check('value LIKE "test%"'), 'varchar(32) CHECK (value LIKE "test%")'],
[Schema::TYPE_STRING . ' NOT NULL', $this->string()->notNull(), 'varchar(255) NOT NULL'],
[Schema::TYPE_TEXT, $this->text(), 'varchar'],
[Schema::TYPE_TEXT . '(255)', $this->text(), 'varchar', Schema::TYPE_TEXT],
[Schema::TYPE_TEXT . ' CHECK (value LIKE "test%")', $this->text()->check('value LIKE "test%"'), 'varchar CHECK (value LIKE "test%")'],
[Schema::TYPE_TEXT . '(255) CHECK (value LIKE "test%")', $this->text()->check('value LIKE "test%"'), 'varchar CHECK (value LIKE "test%")', Schema::TYPE_TEXT . ' CHECK (value LIKE "test%")'],
[Schema::TYPE_TEXT . ' NOT NULL', $this->text()->notNull(), 'varchar NOT NULL'],
[Schema::TYPE_TEXT . '(255) NOT NULL', $this->text()->notNull(), 'varchar NOT NULL', Schema::TYPE_TEXT . ' NOT NULL'],
[Schema::TYPE_SMALLINT, $this->smallInteger(), 'smallint'],
[Schema::TYPE_SMALLINT . '(8)', $this->smallInteger(8), 'smallint'],
[Schema::TYPE_INTEGER, $this->integer(), 'int'],
[Schema::TYPE_INTEGER . '(8)', $this->integer(8), 'int'],
[Schema::TYPE_INTEGER . ' CHECK (value > 5)', $this->integer()->check('value > 5'), 'int CHECK (value > 5)'],
[Schema::TYPE_INTEGER . '(8) CHECK (value > 5)', $this->integer(8)->check('value > 5'), 'int CHECK (value > 5)'],
[Schema::TYPE_INTEGER . ' NOT NULL', $this->integer()->notNull(), 'int NOT NULL'],
[Schema::TYPE_BIGINT, $this->bigInteger(), 'bigint'],
[Schema::TYPE_BIGINT . '(8)', $this->bigInteger(8), 'bigint'],
[Schema::TYPE_BIGINT . ' CHECK (value > 5)', $this->bigInteger()->check('value > 5'), 'bigint CHECK (value > 5)'],
[Schema::TYPE_BIGINT . '(8) CHECK (value > 5)', $this->bigInteger(8)->check('value > 5'), 'bigint CHECK (value > 5)'],
[Schema::TYPE_BIGINT . ' NOT NULL', $this->bigInteger()->notNull(), 'bigint NOT NULL'],
[Schema::TYPE_FLOAT, $this->float(), 'float(7)'],
[Schema::TYPE_FLOAT . '(16)', $this->float(16), 'float(16)'],
[Schema::TYPE_FLOAT . ' CHECK (value > 5.6)', $this->float()->check('value > 5.6'), 'float(7) CHECK (value > 5.6)'],
[Schema::TYPE_FLOAT . '(16) CHECK (value > 5.6)', $this->float(16)->check('value > 5.6'), 'float(16) CHECK (value > 5.6)'],
[Schema::TYPE_FLOAT . ' NOT NULL', $this->float()->notNull(), 'float(7) NOT NULL'],
[Schema::TYPE_DOUBLE, $this->double(), 'double(15)'],
[Schema::TYPE_DOUBLE . '(16)', $this->double(16), 'double(16)'],
[Schema::TYPE_DOUBLE . ' CHECK (value > 5.6)', $this->double()->check('value > 5.6'), 'double(15) CHECK (value > 5.6)'],
[Schema::TYPE_DOUBLE . '(16) CHECK (value > 5.6)', $this->double(16)->check('value > 5.6'), 'double(16) CHECK (value > 5.6)'],
[Schema::TYPE_DOUBLE . ' NOT NULL', $this->double()->notNull(), 'double(15) NOT NULL'],
[Schema::TYPE_DECIMAL, $this->decimal(), 'decimal(10,0)'],
[Schema::TYPE_DECIMAL . '(12,4)', $this->decimal(12, 4), 'decimal(12,4)'],
[Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)', $this->decimal()->check('value > 5.6'), 'decimal(10,0) CHECK (value > 5.6)'],
[Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)', $this->decimal(12, 4)->check('value > 5.6'), 'decimal(12,4) CHECK (value > 5.6)'],
[Schema::TYPE_DECIMAL . ' NOT NULL', $this->decimal()->notNull(), 'decimal(10,0) NOT NULL'],
[Schema::TYPE_DATETIME, $this->dateTime(), 'datetime'],
[Schema::TYPE_DATETIME . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", $this->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', $this->dateTime()->notNull(), 'datetime NOT NULL'],
[Schema::TYPE_TIMESTAMP, $this->timestamp(), 'timestamp'],
[Schema::TYPE_TIMESTAMP . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", $this->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', $this->timestamp()->notNull(), 'timestamp NOT NULL'],
[Schema::TYPE_TIME, $this->time(), 'time'],
[Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')", $this->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', $this->time()->notNull(), 'time NOT NULL'],
[Schema::TYPE_DATE, $this->date(), 'date'],
[Schema::TYPE_DATE . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", $this->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', $this->date()->notNull(), 'date NOT NULL'],
[Schema::TYPE_BINARY, $this->binary(), 'blob'],
[Schema::TYPE_BOOLEAN, $this->boolean(), 'smallint'],
[Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', $this->boolean()->notNull()->defaultValue(1), 'smallint NOT NULL DEFAULT 1'],
[Schema::TYPE_MONEY, $this->money(), 'decimal(19,4)'],
[Schema::TYPE_MONEY . '(16,2)', $this->money(16, 2), 'decimal(16,2)'],
[Schema::TYPE_MONEY . ' CHECK (value > 0.0)', $this->money()->check('value > 0.0'), 'decimal(19,4) CHECK (value > 0.0)'],
[Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)', $this->money(16, 2)->check('value > 0.0'), 'decimal(16,2) CHECK (value > 0.0)'],
[Schema::TYPE_MONEY . ' NOT NULL', $this->money()->notNull(), 'decimal(19,4) NOT NULL'],
[
Schema::TYPE_PK,
$this->primaryKey(),
'int NOT NULL AUTO_INCREMENT PRIMARY KEY'
],
[
Schema::TYPE_PK . '(8)',
$this->primaryKey(8),
'int NOT NULL AUTO_INCREMENT PRIMARY KEY'
],
[
Schema::TYPE_PK . ' CHECK (value > 5)',
$this->primaryKey()->check('value > 5'),
'int NOT NULL AUTO_INCREMENT PRIMARY KEY CHECK (value > 5)'
],
[
Schema::TYPE_PK . '(8) CHECK (value > 5)',
$this->primaryKey(8)->check('value > 5'),
'int NOT NULL AUTO_INCREMENT PRIMARY KEY CHECK (value > 5)'
],
[
Schema::TYPE_CHAR,
$this->char(),
'char(1)'
],
[
Schema::TYPE_CHAR . '(6)',
$this->char(6),
'char(6)'
],
[
Schema::TYPE_CHAR . ' CHECK (value LIKE "test%")',
$this->char()->check('value LIKE "test%"'),
'char(1) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_CHAR . '(6) CHECK (value LIKE "test%")',
$this->char(6)->check('value LIKE "test%"'),
'char(6) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_CHAR . ' NOT NULL',
$this->char()->notNull(),
'char(1) NOT NULL'
],
[
Schema::TYPE_STRING,
$this->string(),
'varchar(255)'
],
[
Schema::TYPE_STRING . '(32)',
$this->string(32),
'varchar(32)'
],
[
Schema::TYPE_STRING . ' CHECK (value LIKE "test%")',
$this->string()->check('value LIKE "test%"'),
'varchar(255) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_STRING . '(32) CHECK (value LIKE "test%")',
$this->string(32)->check('value LIKE "test%"'),
'varchar(32) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_STRING . ' NOT NULL',
$this->string()->notNull(),
'varchar(255) NOT NULL'
],
[
Schema::TYPE_TEXT,
$this->text(),
'varchar'
],
[
Schema::TYPE_TEXT . '(255)',
$this->text(),
'varchar',
],
[
Schema::TYPE_TEXT . ' CHECK (value LIKE "test%")',
$this->text()->check('value LIKE "test%"'),
'varchar CHECK (value LIKE "test%")'
],
[
Schema::TYPE_TEXT . '(255) CHECK (value LIKE "test%")',
$this->text()->check('value LIKE "test%"'),
'varchar CHECK (value LIKE "test%")',
],
[
Schema::TYPE_TEXT . ' NOT NULL',
$this->text()->notNull(),
'varchar NOT NULL'
],
[
Schema::TYPE_TEXT . '(255) NOT NULL',
$this->text()->notNull(),
'varchar NOT NULL',
],
[
Schema::TYPE_SMALLINT,
$this->smallInteger(),
'smallint'
],
[
Schema::TYPE_SMALLINT . '(8)',
$this->smallInteger(8),
'smallint'
],
[
Schema::TYPE_INTEGER,
$this->integer(),
'int'
],
[
Schema::TYPE_INTEGER . '(8)',
$this->integer(8),
'int'
],
[
Schema::TYPE_INTEGER . ' CHECK (value > 5)',
$this->integer()->check('value > 5'),
'int CHECK (value > 5)'
],
[
Schema::TYPE_INTEGER . '(8) CHECK (value > 5)',
$this->integer(8)->check('value > 5'),
'int CHECK (value > 5)'
],
[
Schema::TYPE_INTEGER . ' NOT NULL',
$this->integer()->notNull(),
'int NOT NULL'
],
[
Schema::TYPE_BIGINT,
$this->bigInteger(),
'bigint'
],
[
Schema::TYPE_BIGINT . '(8)',
$this->bigInteger(8),
'bigint'
],
[
Schema::TYPE_BIGINT . ' CHECK (value > 5)',
$this->bigInteger()->check('value > 5'),
'bigint CHECK (value > 5)'
],
[
Schema::TYPE_BIGINT . '(8) CHECK (value > 5)',
$this->bigInteger(8)->check('value > 5'),
'bigint CHECK (value > 5)'
],
[
Schema::TYPE_BIGINT . ' NOT NULL',
$this->bigInteger()->notNull(),
'bigint NOT NULL'
],
[
Schema::TYPE_FLOAT,
$this->float(),
'float(7)'
],
[
Schema::TYPE_FLOAT . '(16)',
$this->float(16),
'float(16)'
],
[
Schema::TYPE_FLOAT . ' CHECK (value > 5.6)',
$this->float()->check('value > 5.6'),
'float(7) CHECK (value > 5.6)'
],
[
Schema::TYPE_FLOAT . '(16) CHECK (value > 5.6)',
$this->float(16)->check('value > 5.6'),
'float(16) CHECK (value > 5.6)'
],
[
Schema::TYPE_FLOAT . ' NOT NULL',
$this->float()->notNull(),
'float(7) NOT NULL'
],
[
Schema::TYPE_DOUBLE,
$this->double(),
'double(15)'
],
[
Schema::TYPE_DOUBLE . '(16)',
$this->double(16),
'double(16)'
],
[
Schema::TYPE_DOUBLE . ' CHECK (value > 5.6)',
$this->double()->check('value > 5.6'),
'double(15) CHECK (value > 5.6)'
],
[
Schema::TYPE_DOUBLE . '(16) CHECK (value > 5.6)',
$this->double(16)->check('value > 5.6'),
'double(16) CHECK (value > 5.6)'
],
[
Schema::TYPE_DOUBLE . ' NOT NULL',
$this->double()->notNull(),
'double(15) NOT NULL'
],
[
Schema::TYPE_DECIMAL,
$this->decimal(),
'decimal(10,0)'
],
[
Schema::TYPE_DECIMAL . '(12,4)',
$this->decimal(12, 4),
'decimal(12,4)'
],
[
Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)',
$this->decimal()->check('value > 5.6'),
'decimal(10,0) CHECK (value > 5.6)'
],
[
Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)',
$this->decimal(12, 4)->check('value > 5.6'),
'decimal(12,4) CHECK (value > 5.6)'
],
[
Schema::TYPE_DECIMAL . ' NOT NULL',
$this->decimal()->notNull(),
'decimal(10,0) NOT NULL'
],
[
Schema::TYPE_DATETIME,
$this->dateTime(),
'datetime'
],
[
Schema::TYPE_DATETIME . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')",
$this->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',
$this->dateTime()->notNull(),
'datetime NOT NULL'
],
[
Schema::TYPE_TIMESTAMP,
$this->timestamp(),
'timestamp'
],
[
Schema::TYPE_TIMESTAMP . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')",
$this->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',
$this->timestamp()->notNull(),
'timestamp NOT NULL'
],
[
Schema::TYPE_TIME,
$this->time(),
'time'
],
[
Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')",
$this->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',
$this->time()->notNull(),
'time NOT NULL'
],
[
Schema::TYPE_DATE,
$this->date(),
'date'
],
[
Schema::TYPE_DATE . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')",
$this->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',
$this->date()->notNull(),
'date NOT NULL'
],
[
Schema::TYPE_BINARY,
$this->binary(),
'blob'
],
[
Schema::TYPE_BOOLEAN,
$this->boolean(),
'smallint'
],
[
Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1',
$this->boolean()->notNull()->defaultValue(1),
'smallint NOT NULL DEFAULT 1'
],
[
Schema::TYPE_MONEY,
$this->money(),
'decimal(19,4)'
],
[
Schema::TYPE_MONEY . '(16,2)',
$this->money(16, 2),
'decimal(16,2)'
],
[
Schema::TYPE_MONEY . ' CHECK (value > 0.0)',
$this->money()->check('value > 0.0'),
'decimal(19,4) CHECK (value > 0.0)'
],
[
Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)',
$this->money(16, 2)->check('value > 0.0'),
'decimal(16,2) CHECK (value > 0.0)'
],
[
Schema::TYPE_MONEY . ' NOT NULL',
$this->money()->notNull(),
'decimal(19,4) NOT NULL'
],
];
}
}

395
tests/framework/db/oci/OracleQueryBuilderTest.php

@ -20,68 +20,339 @@ class OracleQueryBuilderTest extends QueryBuilderTest
public function columnTypes()
{
return [
[Schema::TYPE_PK, $this->primaryKey(), 'NUMBER(10) NOT NULL PRIMARY KEY'],
[Schema::TYPE_PK . '(8)', $this->primaryKey(8), 'NUMBER(8) NOT NULL PRIMARY KEY'],
[Schema::TYPE_PK . ' CHECK (value > 5)', $this->primaryKey()->check('value > 5'), 'NUMBER(10) NOT NULL PRIMARY KEY CHECK (value > 5)'],
[Schema::TYPE_PK . '(8) CHECK (value > 5)', $this->primaryKey(8)->check('value > 5'), 'NUMBER(8) NOT NULL PRIMARY KEY CHECK (value > 5)'],
[Schema::TYPE_STRING, $this->string(), 'VARCHAR2(255)'],
[Schema::TYPE_STRING . '(32)', $this->string(32), 'VARCHAR2(32)'],
[Schema::TYPE_STRING . ' CHECK (value LIKE \'test%\')', $this->string()->check('value LIKE \'test%\''), 'VARCHAR2(255) CHECK (value LIKE \'test%\')'],
[Schema::TYPE_STRING . '(32) CHECK (value LIKE \'test%\')', $this->string(32)->check('value LIKE \'test%\''), 'VARCHAR2(32) CHECK (value LIKE \'test%\')'],
[Schema::TYPE_STRING . ' NOT NULL', $this->string()->notNull(), 'VARCHAR2(255) NOT NULL'],
[Schema::TYPE_TEXT, $this->text(), 'CLOB'],
[Schema::TYPE_TEXT . '(255)', $this->text(), 'CLOB',Schema::TYPE_TEXT],
[Schema::TYPE_TEXT . ' CHECK (value LIKE \'test%\')', $this->text()->check('value LIKE \'test%\''), 'CLOB CHECK (value LIKE \'test%\')'],
[Schema::TYPE_TEXT . '(255) CHECK (value LIKE \'test%\')', $this->text()->check('value LIKE \'test%\''), 'CLOB CHECK (value LIKE \'test%\')', Schema::TYPE_TEXT . ' CHECK (value LIKE \'test%\')'],
[Schema::TYPE_TEXT . ' NOT NULL', $this->text()->notNull(), 'CLOB NOT NULL'],
[Schema::TYPE_TEXT . '(255) NOT NULL', $this->text()->notNull(), 'CLOB NOT NULL', Schema::TYPE_TEXT . ' NOT NULL'],
[Schema::TYPE_SMALLINT, $this->smallInteger(), 'NUMBER(5)'],
[Schema::TYPE_SMALLINT . '(8)', $this->smallInteger(8), 'NUMBER(8)'],
[Schema::TYPE_INTEGER, $this->integer(), 'NUMBER(10)'],
[Schema::TYPE_INTEGER . '(8)', $this->integer(8), 'NUMBER(8)'],
[Schema::TYPE_INTEGER . ' CHECK (value > 5)', $this->integer()->check('value > 5'), 'NUMBER(10) CHECK (value > 5)'],
[Schema::TYPE_INTEGER . '(8) CHECK (value > 5)', $this->integer(8)->check('value > 5'), 'NUMBER(8) CHECK (value > 5)'],
[Schema::TYPE_INTEGER . ' NOT NULL', $this->integer()->notNull(), 'NUMBER(10) NOT NULL'],
[Schema::TYPE_BIGINT, $this->bigInteger(), 'NUMBER(20)'],
[Schema::TYPE_BIGINT . '(8)', $this->bigInteger(8), 'NUMBER(8)'],
[Schema::TYPE_BIGINT . ' CHECK (value > 5)', $this->bigInteger()->check('value > 5'), 'NUMBER(20) CHECK (value > 5)'],
[Schema::TYPE_BIGINT . '(8) CHECK (value > 5)', $this->bigInteger(8)->check('value > 5'), 'NUMBER(8) CHECK (value > 5)'],
[Schema::TYPE_BIGINT . ' NOT NULL', $this->bigInteger()->notNull(), 'NUMBER(20) NOT NULL'],
[Schema::TYPE_FLOAT, $this->float(), 'NUMBER'],
[Schema::TYPE_FLOAT . '(16)', $this->float(16), 'NUMBER'],
[Schema::TYPE_FLOAT . ' CHECK (value > 5.6)', $this->float()->check('value > 5.6'), 'NUMBER CHECK (value > 5.6)'],
[Schema::TYPE_FLOAT . '(16) CHECK (value > 5.6)', $this->float(16)->check('value > 5.6'), 'NUMBER CHECK (value > 5.6)'],
[Schema::TYPE_FLOAT . ' NOT NULL', $this->float()->notNull(), 'NUMBER NOT NULL'],
[Schema::TYPE_DOUBLE, $this->double(), 'NUMBER'],
[Schema::TYPE_DOUBLE . '(16)', $this->double(16), 'NUMBER'],
[Schema::TYPE_DOUBLE . ' CHECK (value > 5.6)', $this->double()->check('value > 5.6'), 'NUMBER CHECK (value > 5.6)'],
[Schema::TYPE_DOUBLE . '(16) CHECK (value > 5.6)', $this->double(16)->check('value > 5.6'), 'NUMBER CHECK (value > 5.6)'],
[Schema::TYPE_DOUBLE . ' NOT NULL', $this->double()->notNull(), 'NUMBER NOT NULL'],
[Schema::TYPE_DECIMAL, $this->decimal(), 'NUMBER'],
[Schema::TYPE_DECIMAL . '(12,4)', $this->decimal(12, 4), 'NUMBER'],
[Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)', $this->decimal()->check('value > 5.6'), 'NUMBER CHECK (value > 5.6)'],
[Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)', $this->decimal(12, 4)->check('value > 5.6'), 'NUMBER CHECK (value > 5.6)'],
[Schema::TYPE_DECIMAL . ' NOT NULL', $this->decimal()->notNull(), 'NUMBER NOT NULL'],
[Schema::TYPE_DATETIME, $this->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', $this->dateTime()->notNull(), 'TIMESTAMP NOT NULL'],
[Schema::TYPE_TIMESTAMP, $this->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', $this->timestamp()->notNull(), 'TIMESTAMP NOT NULL'],
[Schema::TYPE_TIME, $this->time(), 'TIMESTAMP'],
//[Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')", "TIMESTAMP CHECK (value BETWEEN '12:00:00' AND '13:01:01')"],
[Schema::TYPE_TIME . ' NOT NULL', $this->time()->notNull(), 'TIMESTAMP NOT NULL'],
[Schema::TYPE_DATE, $this->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 . ' NOT NULL', $this->date()->notNull(), 'DATE NOT NULL'],
[Schema::TYPE_BINARY, $this->binary(), 'BLOB'],
[Schema::TYPE_BOOLEAN, $this->boolean(), 'NUMBER(1)'],
[Schema::TYPE_BOOLEAN . ' DEFAULT 1 NOT NULL', $this->boolean()->notNull()->defaultValue(1), 'NUMBER(1) DEFAULT 1 NOT NULL'],
[Schema::TYPE_MONEY, $this->money(), 'NUMBER(19,4)'],
[Schema::TYPE_MONEY . '(16,2)', $this->money(16, 2), 'NUMBER(16,2)'],
[Schema::TYPE_MONEY . ' CHECK (value > 0.0)', $this->money()->check('value > 0.0'), 'NUMBER(19,4) CHECK (value > 0.0)'],
[Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)', $this->money(16, 2)->check('value > 0.0'), 'NUMBER(16,2) CHECK (value > 0.0)'],
[Schema::TYPE_MONEY . ' NOT NULL', $this->money()->notNull(), 'NUMBER(19,4) NOT NULL'],
[
Schema::TYPE_PK,
$this->primaryKey(),
'NUMBER(10) NOT NULL PRIMARY KEY'
],
[
Schema::TYPE_PK . '(8)',
$this->primaryKey(8),
'NUMBER(8) NOT NULL PRIMARY KEY'
],
[
Schema::TYPE_PK . ' CHECK (value > 5)',
$this->primaryKey()->check('value > 5'),
'NUMBER(10) NOT NULL PRIMARY KEY CHECK (value > 5)'
],
[
Schema::TYPE_PK . '(8) CHECK (value > 5)',
$this->primaryKey(8)->check('value > 5'),
'NUMBER(8) NOT NULL PRIMARY KEY CHECK (value > 5)'
],
[
Schema::TYPE_CHAR,
$this->char(),
'CHAR(1)'
],
[
Schema::TYPE_CHAR . '(6)',
$this->char(6),
'CHAR(6)'
],
[
Schema::TYPE_CHAR . ' CHECK (value LIKE "test%")',
$this->char()->check('value LIKE "test%"'),
'CHAR(1) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_CHAR . '(6) CHECK (value LIKE "test%")',
$this->char(6)->check('value LIKE "test%"'),
'CHAR(6) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_CHAR . ' NOT NULL',
$this->char()->notNull(),
'CHAR(1) NOT NULL'
],
[
Schema::TYPE_STRING,
$this->string(),
'VARCHAR2(255)'
],
[
Schema::TYPE_STRING . '(32)',
$this->string(32),
'VARCHAR2(32)'
],
[
Schema::TYPE_STRING . ' CHECK (value LIKE \'test%\')',
$this->string()->check('value LIKE \'test%\''),
'VARCHAR2(255) CHECK (value LIKE \'test%\')'
],
[
Schema::TYPE_STRING . '(32) CHECK (value LIKE \'test%\')',
$this->string(32)->check('value LIKE \'test%\''),
'VARCHAR2(32) CHECK (value LIKE \'test%\')'
],
[
Schema::TYPE_STRING . ' NOT NULL',
$this->string()->notNull(),
'VARCHAR2(255) NOT NULL'
],
[
Schema::TYPE_TEXT,
$this->text(),
'CLOB'
],
[
Schema::TYPE_TEXT . '(255)',
$this->text(),
'CLOB',Schema::TYPE_TEXT
],
[
Schema::TYPE_TEXT . ' CHECK (value LIKE \'test%\')',
$this->text()->check('value LIKE \'test%\''),
'CLOB CHECK (value LIKE \'test%\')'
],
[
Schema::TYPE_TEXT . '(255) CHECK (value LIKE \'test%\')',
$this->text()->check('value LIKE \'test%\''),
'CLOB CHECK (value LIKE \'test%\')',
Schema::TYPE_TEXT . ' CHECK (value LIKE \'test%\')'
],
[
Schema::TYPE_TEXT . ' NOT NULL',
$this->text()->notNull(),
'CLOB NOT NULL'
],
[
Schema::TYPE_TEXT . '(255) NOT NULL',
$this->text()->notNull(),
'CLOB NOT NULL',
Schema::TYPE_TEXT . ' NOT NULL'
],
[
Schema::TYPE_SMALLINT,
$this->smallInteger(),
'NUMBER(5)'
],
[
Schema::TYPE_SMALLINT . '(8)',
$this->smallInteger(8),
'NUMBER(8)'
],
[
Schema::TYPE_INTEGER,
$this->integer(),
'NUMBER(10)'
],
[
Schema::TYPE_INTEGER . '(8)',
$this->integer(8),
'NUMBER(8)'
],
[
Schema::TYPE_INTEGER . ' CHECK (value > 5)',
$this->integer()->check('value > 5'),
'NUMBER(10) CHECK (value > 5)'
],
[
Schema::TYPE_INTEGER . '(8) CHECK (value > 5)',
$this->integer(8)->check('value > 5'),
'NUMBER(8) CHECK (value > 5)'
],
[
Schema::TYPE_INTEGER . ' NOT NULL',
$this->integer()->notNull(),
'NUMBER(10) NOT NULL'
],
[
Schema::TYPE_BIGINT,
$this->bigInteger(),
'NUMBER(20)'
],
[
Schema::TYPE_BIGINT . '(8)',
$this->bigInteger(8),
'NUMBER(8)'
],
[
Schema::TYPE_BIGINT . ' CHECK (value > 5)',
$this->bigInteger()->check('value > 5'),
'NUMBER(20) CHECK (value > 5)'
],
[
Schema::TYPE_BIGINT . '(8) CHECK (value > 5)',
$this->bigInteger(8)->check('value > 5'),
'NUMBER(8) CHECK (value > 5)'
],
[
Schema::TYPE_BIGINT . ' NOT NULL',
$this->bigInteger()->notNull(),
'NUMBER(20) NOT NULL'
],
[
Schema::TYPE_FLOAT,
$this->float(),
'NUMBER'
],
[
Schema::TYPE_FLOAT . '(16)',
$this->float(16),
'NUMBER'
],
[
Schema::TYPE_FLOAT . ' CHECK (value > 5.6)',
$this->float()->check('value > 5.6'),
'NUMBER CHECK (value > 5.6)'
],
[
Schema::TYPE_FLOAT . '(16) CHECK (value > 5.6)',
$this->float(16)->check('value > 5.6'),
'NUMBER CHECK (value > 5.6)'
],
[
Schema::TYPE_FLOAT . ' NOT NULL',
$this->float()->notNull(),
'NUMBER NOT NULL'
],
[
Schema::TYPE_DOUBLE,
$this->double(),
'NUMBER'
],
[
Schema::TYPE_DOUBLE . '(16)',
$this->double(16),
'NUMBER'
],
[
Schema::TYPE_DOUBLE . ' CHECK (value > 5.6)',
$this->double()->check('value > 5.6'),
'NUMBER CHECK (value > 5.6)'
],
[
Schema::TYPE_DOUBLE . '(16) CHECK (value > 5.6)',
$this->double(16)->check('value > 5.6'),
'NUMBER CHECK (value > 5.6)'
],
[
Schema::TYPE_DOUBLE . ' NOT NULL',
$this->double()->notNull(),
'NUMBER NOT NULL'
],
[
Schema::TYPE_DECIMAL,
$this->decimal(),
'NUMBER'
],
[
Schema::TYPE_DECIMAL . '(12,4)',
$this->decimal(12, 4),
'NUMBER'
],
[
Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)',
$this->decimal()->check('value > 5.6'),
'NUMBER CHECK (value > 5.6)'
],
[
Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)',
$this->decimal(12, 4)->check('value > 5.6'),
'NUMBER CHECK (value > 5.6)'
],
[
Schema::TYPE_DECIMAL . ' NOT NULL',
$this->decimal()->notNull(),
'NUMBER NOT NULL'
],
[
Schema::TYPE_DATETIME,
$this->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',
$this->dateTime()->notNull(),
'TIMESTAMP NOT NULL'
],
[
Schema::TYPE_TIMESTAMP,
$this->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',
$this->timestamp()->notNull(),
'TIMESTAMP NOT NULL'
],
[
Schema::TYPE_TIME,
$this->time(),
'TIMESTAMP'
],
[
Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')",
"TIMESTAMP CHECK (value BETWEEN '12:00:00' AND '13:01:01')"
],
[
Schema::TYPE_TIME . ' NOT NULL',
$this->time()->notNull(),
'TIMESTAMP NOT NULL'
],
[
Schema::TYPE_DATE,
$this->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 . ' NOT NULL',
$this->date()->notNull(),
'DATE NOT NULL'
],
[
Schema::TYPE_BINARY,
$this->binary(),
'BLOB'
],
[
Schema::TYPE_BOOLEAN,
$this->boolean(),
'NUMBER(1)'
],
[
Schema::TYPE_BOOLEAN . ' DEFAULT 1 NOT NULL',
$this->boolean()->notNull()->defaultValue(1),
'NUMBER(1) DEFAULT 1 NOT NULL'
],
[
Schema::TYPE_MONEY,
$this->money(),
'NUMBER(19,4)'
],
[
Schema::TYPE_MONEY . '(16,2)',
$this->money(16, 2),
'NUMBER(16,2)'
],
[
Schema::TYPE_MONEY . ' CHECK (value > 0.0)',
$this->money()->check('value > 0.0'),
'NUMBER(19,4) CHECK (value > 0.0)'
],
[
Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)',
$this->money(16, 2)->check('value > 0.0'),
'NUMBER(16,2) CHECK (value > 0.0)'
],
[
Schema::TYPE_MONEY . ' NOT NULL',
$this->money()->notNull(),
'NUMBER(19,4) NOT NULL'
],
];
}
}

391
tests/framework/db/pgsql/PostgreSQLQueryBuilderTest.php

@ -16,67 +16,336 @@ class PostgreSQLQueryBuilderTest extends QueryBuilderTest
public function columnTypes()
{
return [
[Schema::TYPE_PK, $this->primaryKey(), 'serial NOT NULL PRIMARY KEY'],
[Schema::TYPE_PK . '(8)', $this->primaryKey(8), 'serial NOT NULL PRIMARY KEY'],
[Schema::TYPE_PK . ' CHECK (value > 5)', $this->primaryKey()->check('value > 5'), 'serial NOT NULL PRIMARY KEY CHECK (value > 5)'],
[Schema::TYPE_PK . '(8) CHECK (value > 5)', $this->primaryKey(8)->check('value > 5'), 'serial NOT NULL PRIMARY KEY CHECK (value > 5)'],
[Schema::TYPE_STRING, $this->string(), 'varchar(255)'],
[Schema::TYPE_STRING . '(32)', $this->string(32), 'varchar(32)'],
[Schema::TYPE_STRING . ' CHECK (value LIKE \'test%\')', $this->string()->check('value LIKE \'test%\''), 'varchar(255) CHECK (value LIKE \'test%\')'],
[Schema::TYPE_STRING . '(32) CHECK (value LIKE \'test%\')', $this->string(32)->check('value LIKE \'test%\''), 'varchar(32) CHECK (value LIKE \'test%\')'],
[Schema::TYPE_STRING . ' NOT NULL', $this->string()->notNull(), 'varchar(255) NOT NULL'],
[Schema::TYPE_TEXT, $this->text(), 'text'],
[Schema::TYPE_TEXT . '(255)', $this->text(), 'text', Schema::TYPE_TEXT],
[Schema::TYPE_TEXT . ' CHECK (value LIKE \'test%\')', $this->text()->check('value LIKE \'test%\''), 'text CHECK (value LIKE \'test%\')'],
[Schema::TYPE_TEXT . '(255) CHECK (value LIKE \'test%\')', $this->text()->check('value LIKE \'test%\''), 'text CHECK (value LIKE \'test%\')', Schema::TYPE_TEXT . ' CHECK (value LIKE \'test%\')'],
[Schema::TYPE_TEXT . ' NOT NULL', $this->text()->notNull(), 'text NOT NULL'],
[Schema::TYPE_TEXT . '(255) NOT NULL', $this->text()->notNull(), 'text NOT NULL', Schema::TYPE_TEXT . ' NOT NULL'],
[Schema::TYPE_SMALLINT, $this->smallInteger(), 'smallint'],
[Schema::TYPE_SMALLINT . '(8)', $this->smallInteger(8), 'smallint'],
[Schema::TYPE_INTEGER, $this->integer(), 'integer'],
[Schema::TYPE_INTEGER . '(8)', $this->integer(8), 'integer'],
[Schema::TYPE_INTEGER . ' CHECK (value > 5)', $this->integer()->check('value > 5'), 'integer CHECK (value > 5)'],
[Schema::TYPE_INTEGER . '(8) CHECK (value > 5)', $this->integer(8)->check('value > 5'), 'integer CHECK (value > 5)'],
[Schema::TYPE_INTEGER . ' NOT NULL', $this->integer()->notNull(), 'integer NOT NULL'],
[Schema::TYPE_BIGINT, $this->bigInteger(), 'bigint'],
[Schema::TYPE_BIGINT . '(8)', $this->bigInteger(8), 'bigint'],
[Schema::TYPE_BIGINT . ' CHECK (value > 5)', $this->bigInteger()->check('value > 5'), 'bigint CHECK (value > 5)'],
[Schema::TYPE_BIGINT . '(8) CHECK (value > 5)', $this->bigInteger(8)->check('value > 5'), 'bigint CHECK (value > 5)'],
[Schema::TYPE_BIGINT . ' NOT NULL', $this->bigInteger()->notNull(), 'bigint NOT NULL'],
[Schema::TYPE_FLOAT, $this->float(), 'double precision'],
[Schema::TYPE_FLOAT . ' CHECK (value > 5.6)', $this->float()->check('value > 5.6'), 'double precision CHECK (value > 5.6)'],
[Schema::TYPE_FLOAT . '(16) CHECK (value > 5.6)', $this->float(16)->check('value > 5.6'), 'double precision CHECK (value > 5.6)'],
[Schema::TYPE_FLOAT . ' NOT NULL', $this->float()->notNull(), 'double precision NOT NULL'],
[Schema::TYPE_DOUBLE, $this->double(), 'double precision'],
[Schema::TYPE_DOUBLE . ' CHECK (value > 5.6)', $this->double()->check('value > 5.6'), 'double precision CHECK (value > 5.6)'],
[Schema::TYPE_DOUBLE . '(16) CHECK (value > 5.6)', $this->double(16)->check('value > 5.6'), 'double precision CHECK (value > 5.6)'],
[Schema::TYPE_DOUBLE . ' NOT NULL', $this->double()->notNull(), 'double precision NOT NULL'],
[Schema::TYPE_DECIMAL, $this->decimal(), 'numeric(10,0)'],
[Schema::TYPE_DECIMAL . '(12,4)', $this->decimal(12, 4), 'numeric(12,4)'],
[Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)', $this->decimal()->check('value > 5.6'), 'numeric(10,0) CHECK (value > 5.6)'],
[Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)', $this->decimal(12, 4)->check('value > 5.6'), 'numeric(12,4) CHECK (value > 5.6)'],
[Schema::TYPE_DECIMAL . ' NOT NULL', $this->decimal()->notNull(), 'numeric(10,0) NOT NULL'],
[Schema::TYPE_DATETIME, $this->dateTime(), 'timestamp(0)'],
[Schema::TYPE_DATETIME . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", $this->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', $this->dateTime()->notNull(), 'timestamp(0) NOT NULL'],
[Schema::TYPE_TIMESTAMP, $this->timestamp(), 'timestamp(0)'],
[Schema::TYPE_TIMESTAMP . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", $this->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', $this->timestamp()->notNull(), 'timestamp(0) NOT NULL'],
[Schema::TYPE_TIMESTAMP . '(4)', $this->timestamp(4), 'timestamp(4)'],
[Schema::TYPE_TIME, $this->time(), 'time(0)'],
[Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')", $this->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', $this->time()->notNull(), 'time(0) NOT NULL'],
[Schema::TYPE_DATE, $this->date(), 'date'],
[Schema::TYPE_DATE . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", $this->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', $this->date()->notNull(), 'date NOT NULL'],
[Schema::TYPE_BINARY, $this->binary(), 'bytea'],
[Schema::TYPE_BOOLEAN, $this->boolean(), 'boolean'],
[Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT TRUE', $this->boolean()->notNull()->defaultValue(true), 'boolean NOT NULL DEFAULT TRUE'],
[Schema::TYPE_MONEY, $this->money(), 'numeric(19,4)'],
[Schema::TYPE_MONEY . '(16,2)', $this->money(16, 2), 'numeric(16,2)'],
[Schema::TYPE_MONEY . ' CHECK (value > 0.0)', $this->money()->check('value > 0.0'), 'numeric(19,4) CHECK (value > 0.0)'],
[Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)', $this->money(16, 2)->check('value > 0.0'), 'numeric(16,2) CHECK (value > 0.0)'],
[Schema::TYPE_MONEY . ' NOT NULL', $this->money()->notNull(), 'numeric(19,4) NOT NULL'],
[
Schema::TYPE_PK,
$this->primaryKey(),
'serial NOT NULL PRIMARY KEY'
],
[
Schema::TYPE_PK . '(8)',
$this->primaryKey(8),
'serial NOT NULL PRIMARY KEY'
],
[
Schema::TYPE_PK . ' CHECK (value > 5)',
$this->primaryKey()->check('value > 5'),
'serial NOT NULL PRIMARY KEY CHECK (value > 5)'
],
[
Schema::TYPE_PK . '(8) CHECK (value > 5)',
$this->primaryKey(8)->check('value > 5'),
'serial NOT NULL PRIMARY KEY CHECK (value > 5)'
],
[
Schema::TYPE_CHAR,
$this->char(),
'char(1)'
],
[
Schema::TYPE_CHAR . '(6)',
$this->char(6),
'char(6)'
],
[
Schema::TYPE_CHAR . ' CHECK (value LIKE \'test%\')',
$this->char()->check('value LIKE \'test%\''),
'char(1) CHECK (value LIKE \'test%\')'
],
[
Schema::TYPE_CHAR . '(6) CHECK (value LIKE \'test%\')',
$this->char(6)->check('value LIKE \'test%\''),
'char(6) CHECK (value LIKE \'test%\')'
],
[
Schema::TYPE_CHAR . ' NOT NULL',
$this->char()->notNull(),
'char(1) NOT NULL'
],
[
Schema::TYPE_STRING,
$this->string(),
'varchar(255)'
],
[
Schema::TYPE_STRING . '(32)',
$this->string(32),
'varchar(32)'
],
[
Schema::TYPE_STRING . ' CHECK (value LIKE \'test%\')',
$this->string()->check('value LIKE \'test%\''),
'varchar(255) CHECK (value LIKE \'test%\')'
],
[
Schema::TYPE_STRING . '(32) CHECK (value LIKE \'test%\')',
$this->string(32)->check('value LIKE \'test%\''),
'varchar(32) CHECK (value LIKE \'test%\')'
],
[
Schema::TYPE_STRING . ' NOT NULL',
$this->string()->notNull(),
'varchar(255) NOT NULL'
],
[
Schema::TYPE_TEXT,
$this->text(),
'text'
],
[
Schema::TYPE_TEXT . '(255)',
$this->text(),
'text',
],
[
Schema::TYPE_TEXT . ' CHECK (value LIKE \'test%\')',
$this->text()->check('value LIKE \'test%\''),
'text CHECK (value LIKE \'test%\')'
],
[
Schema::TYPE_TEXT . '(255) CHECK (value LIKE \'test%\')',
$this->text()->check('value LIKE \'test%\''),
'text CHECK (value LIKE \'test%\')',
],
[
Schema::TYPE_TEXT . ' NOT NULL',
$this->text()->notNull(),
'text NOT NULL'
],
[
Schema::TYPE_TEXT . '(255) NOT NULL',
$this->text()->notNull(),
'text NOT NULL',
],
[
Schema::TYPE_SMALLINT,
$this->smallInteger(),
'smallint'
],
[
Schema::TYPE_SMALLINT . '(8)',
$this->smallInteger(8),
'smallint'
],
[
Schema::TYPE_INTEGER,
$this->integer(),
'integer'
],
[
Schema::TYPE_INTEGER . '(8)',
$this->integer(8),
'integer'
],
[
Schema::TYPE_INTEGER . ' CHECK (value > 5)',
$this->integer()->check('value > 5'),
'integer CHECK (value > 5)'
],
[
Schema::TYPE_INTEGER . '(8) CHECK (value > 5)',
$this->integer(8)->check('value > 5'),
'integer CHECK (value > 5)'
],
[
Schema::TYPE_INTEGER . ' NOT NULL',
$this->integer()->notNull(),
'integer NOT NULL'
],
[
Schema::TYPE_BIGINT,
$this->bigInteger(),
'bigint'
],
[
Schema::TYPE_BIGINT . '(8)',
$this->bigInteger(8),
'bigint'
],
[
Schema::TYPE_BIGINT . ' CHECK (value > 5)',
$this->bigInteger()->check('value > 5'),
'bigint CHECK (value > 5)'
],
[
Schema::TYPE_BIGINT . '(8) CHECK (value > 5)',
$this->bigInteger(8)->check('value > 5'),
'bigint CHECK (value > 5)'
],
[
Schema::TYPE_BIGINT . ' NOT NULL',
$this->bigInteger()->notNull(),
'bigint NOT NULL'
],
[
Schema::TYPE_FLOAT,
$this->float(),
'double precision'
],
[
Schema::TYPE_FLOAT . ' CHECK (value > 5.6)',
$this->float()->check('value > 5.6'),
'double precision CHECK (value > 5.6)'
],
[
Schema::TYPE_FLOAT . '(16) CHECK (value > 5.6)',
$this->float(16)->check('value > 5.6'),
'double precision CHECK (value > 5.6)'
],
[
Schema::TYPE_FLOAT . ' NOT NULL',
$this->float()->notNull(),
'double precision NOT NULL'
],
[
Schema::TYPE_DOUBLE,
$this->double(),
'double precision'
],
[
Schema::TYPE_DOUBLE . ' CHECK (value > 5.6)',
$this->double()->check('value > 5.6'),
'double precision CHECK (value > 5.6)'
],
[
Schema::TYPE_DOUBLE . '(16) CHECK (value > 5.6)',
$this->double(16)->check('value > 5.6'),
'double precision CHECK (value > 5.6)'
],
[
Schema::TYPE_DOUBLE . ' NOT NULL',
$this->double()->notNull(),
'double precision NOT NULL'
],
[
Schema::TYPE_DECIMAL,
$this->decimal(),
'numeric(10,0)'
],
[
Schema::TYPE_DECIMAL . '(12,4)',
$this->decimal(12, 4),
'numeric(12,4)'
],
[
Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)',
$this->decimal()->check('value > 5.6'),
'numeric(10,0) CHECK (value > 5.6)'
],
[
Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)',
$this->decimal(12, 4)->check('value > 5.6'),
'numeric(12,4) CHECK (value > 5.6)'
],
[
Schema::TYPE_DECIMAL . ' NOT NULL',
$this->decimal()->notNull(),
'numeric(10,0) NOT NULL'
],
[
Schema::TYPE_DATETIME,
$this->dateTime(),
'timestamp(0)'
],
[
Schema::TYPE_DATETIME . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')",
$this->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',
$this->dateTime()->notNull(),
'timestamp(0) NOT NULL'
],
[
Schema::TYPE_TIMESTAMP,
$this->timestamp(),
'timestamp(0)'
],
[
Schema::TYPE_TIMESTAMP . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')",
$this->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',
$this->timestamp()->notNull(),
'timestamp(0) NOT NULL'
],
[
Schema::TYPE_TIMESTAMP . '(4)',
$this->timestamp(4),
'timestamp(4)'
],
[
Schema::TYPE_TIME,
$this->time(),
'time(0)'
],
[
Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')",
$this->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',
$this->time()->notNull(),
'time(0) NOT NULL'
],
[
Schema::TYPE_DATE,
$this->date(),
'date'
],
[
Schema::TYPE_DATE . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')",
$this->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',
$this->date()->notNull(),
'date NOT NULL'
],
[
Schema::TYPE_BINARY,
$this->binary(),
'bytea'
],
[
Schema::TYPE_BOOLEAN,
$this->boolean(),
'boolean'
],
[
Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT TRUE',
$this->boolean()->notNull()->defaultValue(true),
'boolean NOT NULL DEFAULT TRUE'
],
[
Schema::TYPE_MONEY,
$this->money(),
'numeric(19,4)'
],
[
Schema::TYPE_MONEY . '(16,2)',
$this->money(16, 2),
'numeric(16,2)'
],
[
Schema::TYPE_MONEY . ' CHECK (value > 0.0)',
$this->money()->check('value > 0.0'),
'numeric(19,4) CHECK (value > 0.0)'
],
[
Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)',
$this->money(16, 2)->check('value > 0.0'),
'numeric(16,2) CHECK (value > 0.0)'
],
[
Schema::TYPE_MONEY . ' NOT NULL',
$this->money()->notNull(),
'numeric(19,4) NOT NULL'
],
];
}

397
tests/framework/db/sqlite/SqliteQueryBuilderTest.php

@ -17,68 +17,341 @@ class SqliteQueryBuilderTest extends QueryBuilderTest
public function columnTypes()
{
return [
[Schema::TYPE_PK, $this->primaryKey(), 'integer PRIMARY KEY AUTOINCREMENT NOT NULL'],
[Schema::TYPE_PK . '(8)', $this->primaryKey(8), 'integer PRIMARY KEY AUTOINCREMENT NOT NULL'],
[Schema::TYPE_PK . ' CHECK (value > 5)', $this->primaryKey()->check('value > 5'), 'integer PRIMARY KEY AUTOINCREMENT NOT NULL CHECK (value > 5)'],
[Schema::TYPE_PK . '(8) CHECK (value > 5)', $this->primaryKey(8)->check('value > 5'), 'integer PRIMARY KEY AUTOINCREMENT NOT NULL CHECK (value > 5)'],
[Schema::TYPE_STRING, $this->string(), 'varchar(255)'],
[Schema::TYPE_STRING . '(32)', $this->string(32), 'varchar(32)'],
[Schema::TYPE_STRING . ' CHECK (value LIKE "test%")', $this->string()->check('value LIKE "test%"'), 'varchar(255) CHECK (value LIKE "test%")'],
[Schema::TYPE_STRING . '(32) CHECK (value LIKE "test%")', $this->string(32)->check('value LIKE "test%"'), 'varchar(32) CHECK (value LIKE "test%")'],
[Schema::TYPE_STRING . ' NOT NULL', $this->string()->notNull(), 'varchar(255) NOT NULL'],
[Schema::TYPE_TEXT, $this->text(), 'text'],
[Schema::TYPE_TEXT . '(255)', $this->text(), 'text', Schema::TYPE_TEXT],
[Schema::TYPE_TEXT . ' CHECK (value LIKE "test%")', $this->text()->check('value LIKE "test%"'), 'text CHECK (value LIKE "test%")'],
[Schema::TYPE_TEXT . '(255) CHECK (value LIKE "test%")', $this->text()->check('value LIKE "test%"'), 'text CHECK (value LIKE "test%")', Schema::TYPE_TEXT . ' CHECK (value LIKE "test%")'],
[Schema::TYPE_TEXT . ' NOT NULL', $this->text()->notNull(), 'text NOT NULL'],
[Schema::TYPE_TEXT . '(255) NOT NULL', $this->text()->notNull(), 'text NOT NULL', Schema::TYPE_TEXT . ' NOT NULL'],
[Schema::TYPE_SMALLINT, $this->smallInteger(), 'smallint'],
[Schema::TYPE_SMALLINT . '(8)', $this->smallInteger(8), 'smallint'],
[Schema::TYPE_INTEGER, $this->integer(), 'integer'],
[Schema::TYPE_INTEGER . '(8)', $this->integer(8), 'integer'],
[Schema::TYPE_INTEGER . ' CHECK (value > 5)', $this->integer()->check('value > 5'), 'integer CHECK (value > 5)'],
[Schema::TYPE_INTEGER . '(8) CHECK (value > 5)', $this->integer(8)->check('value > 5'), 'integer CHECK (value > 5)'],
[Schema::TYPE_INTEGER . ' NOT NULL', $this->integer()->notNull(), 'integer NOT NULL'],
[Schema::TYPE_BIGINT, $this->bigInteger(), 'bigint'],
[Schema::TYPE_BIGINT . '(8)', $this->bigInteger(8), 'bigint'],
[Schema::TYPE_BIGINT . ' CHECK (value > 5)', $this->bigInteger()->check('value > 5'), 'bigint CHECK (value > 5)'],
[Schema::TYPE_BIGINT . '(8) CHECK (value > 5)', $this->bigInteger(8)->check('value > 5'), 'bigint CHECK (value > 5)'],
[Schema::TYPE_BIGINT . ' NOT NULL', $this->bigInteger()->notNull(), 'bigint NOT NULL'],
[Schema::TYPE_FLOAT, $this->float(), 'float'],
[Schema::TYPE_FLOAT . '(16)', $this->float(16), 'float'],
[Schema::TYPE_FLOAT . ' CHECK (value > 5.6)', $this->float()->check('value > 5.6'), 'float CHECK (value > 5.6)'],
[Schema::TYPE_FLOAT . '(16) CHECK (value > 5.6)', $this->float(16)->check('value > 5.6'), 'float CHECK (value > 5.6)'],
[Schema::TYPE_FLOAT . ' NOT NULL', $this->float()->notNull(), 'float NOT NULL'],
[Schema::TYPE_DOUBLE, $this->double(), 'double'],
[Schema::TYPE_DOUBLE . '(16)', $this->double(16), 'double'],
[Schema::TYPE_DOUBLE . ' CHECK (value > 5.6)', $this->double()->check('value > 5.6'), 'double CHECK (value > 5.6)'],
[Schema::TYPE_DOUBLE . '(16) CHECK (value > 5.6)', $this->double(16)->check('value > 5.6'), 'double CHECK (value > 5.6)'],
[Schema::TYPE_DOUBLE . ' NOT NULL', $this->double()->notNull(), 'double NOT NULL'],
[Schema::TYPE_DECIMAL, $this->decimal(), 'decimal(10,0)'],
[Schema::TYPE_DECIMAL . '(12,4)', $this->decimal(12, 4), 'decimal(12,4)'],
[Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)', $this->decimal()->check('value > 5.6'), 'decimal(10,0) CHECK (value > 5.6)'],
[Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)', $this->decimal(12, 4)->check('value > 5.6'), 'decimal(12,4) CHECK (value > 5.6)'],
[Schema::TYPE_DECIMAL . ' NOT NULL', $this->decimal()->notNull(), 'decimal(10,0) NOT NULL'],
[Schema::TYPE_DATETIME, $this->dateTime(), 'datetime'],
[Schema::TYPE_DATETIME . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", $this->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', $this->dateTime()->notNull(), 'datetime NOT NULL'],
[Schema::TYPE_TIMESTAMP, $this->timestamp(), 'timestamp'],
[Schema::TYPE_TIMESTAMP . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", $this->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', $this->timestamp()->notNull(), 'timestamp NOT NULL'],
[Schema::TYPE_TIME, $this->time(), 'time'],
[Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')", $this->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', $this->time()->notNull(), 'time NOT NULL'],
[Schema::TYPE_DATE, $this->date(), 'date'],
[Schema::TYPE_DATE . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", $this->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', $this->date()->notNull(), 'date NOT NULL'],
[Schema::TYPE_BINARY, $this->binary(), 'blob'],
[Schema::TYPE_BOOLEAN, $this->boolean(), 'boolean'],
[Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', $this->boolean()->notNull()->defaultValue(1), 'boolean NOT NULL DEFAULT 1'],
[Schema::TYPE_MONEY, $this->money(), 'decimal(19,4)'],
[Schema::TYPE_MONEY . '(16,2)', $this->money(16, 2), 'decimal(16,2)'],
[Schema::TYPE_MONEY . ' CHECK (value > 0.0)', $this->money()->check('value > 0.0'), 'decimal(19,4) CHECK (value > 0.0)'],
[Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)', $this->money(16, 2)->check('value > 0.0'), 'decimal(16,2) CHECK (value > 0.0)'],
[Schema::TYPE_MONEY . ' NOT NULL', $this->money()->notNull(), 'decimal(19,4) NOT NULL'],
[
Schema::TYPE_PK,
$this->primaryKey(),
'integer PRIMARY KEY AUTOINCREMENT NOT NULL'
],
[
Schema::TYPE_PK . '(8)',
$this->primaryKey(8),
'integer PRIMARY KEY AUTOINCREMENT NOT NULL'
],
[
Schema::TYPE_PK . ' CHECK (value > 5)',
$this->primaryKey()->check('value > 5'),
'integer PRIMARY KEY AUTOINCREMENT NOT NULL CHECK (value > 5)'
],
[
Schema::TYPE_PK . '(8) CHECK (value > 5)',
$this->primaryKey(8)->check('value > 5'),
'integer PRIMARY KEY AUTOINCREMENT NOT NULL CHECK (value > 5)'
],
[
Schema::TYPE_CHAR,
$this->char(),
'char(1)'
],
[
Schema::TYPE_CHAR . '(6)',
$this->char(6),
'char(6)'
],
[
Schema::TYPE_CHAR . ' CHECK (value LIKE "test%")',
$this->char()->check('value LIKE "test%"'),
'char(1) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_CHAR . '(6) CHECK (value LIKE "test%")',
$this->char(6)->check('value LIKE "test%"'),
'char(6) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_CHAR . ' NOT NULL',
$this->char()->notNull(),
'char(1) NOT NULL'
],
[
Schema::TYPE_STRING,
$this->string(),
'varchar(255)'
],
[
Schema::TYPE_STRING . '(32)',
$this->string(32),
'varchar(32)'
],
[
Schema::TYPE_STRING . ' CHECK (value LIKE "test%")',
$this->string()->check('value LIKE "test%"'),
'varchar(255) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_STRING . '(32) CHECK (value LIKE "test%")',
$this->string(32)->check('value LIKE "test%"'),
'varchar(32) CHECK (value LIKE "test%")'
],
[
Schema::TYPE_STRING . ' NOT NULL',
$this->string()->notNull(),
'varchar(255) NOT NULL'
],
[
Schema::TYPE_TEXT,
$this->text(),
'text'
],
[
Schema::TYPE_TEXT . '(255)',
$this->text(),
'text',
],
[
Schema::TYPE_TEXT . ' CHECK (value LIKE "test%")',
$this->text()->check('value LIKE "test%"'),
'text CHECK (value LIKE "test%")'
],
[
Schema::TYPE_TEXT . '(255) CHECK (value LIKE "test%")',
$this->text()->check('value LIKE "test%"'),
'text CHECK (value LIKE "test%")',
],
[
Schema::TYPE_TEXT . ' NOT NULL',
$this->text()->notNull(),
'text NOT NULL'
],
[
Schema::TYPE_TEXT . '(255) NOT NULL',
$this->text()->notNull(),
'text NOT NULL',
],
[
Schema::TYPE_SMALLINT,
$this->smallInteger(),
'smallint'
],
[
Schema::TYPE_SMALLINT . '(8)',
$this->smallInteger(8),
'smallint'
],
[
Schema::TYPE_INTEGER,
$this->integer(),
'integer'
],
[
Schema::TYPE_INTEGER . '(8)',
$this->integer(8),
'integer'
],
[
Schema::TYPE_INTEGER . ' CHECK (value > 5)',
$this->integer()->check('value > 5'),
'integer CHECK (value > 5)'
],
[
Schema::TYPE_INTEGER . '(8) CHECK (value > 5)',
$this->integer(8)->check('value > 5'),
'integer CHECK (value > 5)'
],
[
Schema::TYPE_INTEGER . ' NOT NULL',
$this->integer()->notNull(),
'integer NOT NULL'
],
[
Schema::TYPE_BIGINT,
$this->bigInteger(),
'bigint'
],
[
Schema::TYPE_BIGINT . '(8)',
$this->bigInteger(8),
'bigint'
],
[
Schema::TYPE_BIGINT . ' CHECK (value > 5)',
$this->bigInteger()->check('value > 5'),
'bigint CHECK (value > 5)'
],
[
Schema::TYPE_BIGINT . '(8) CHECK (value > 5)',
$this->bigInteger(8)->check('value > 5'),
'bigint CHECK (value > 5)'
],
[
Schema::TYPE_BIGINT . ' NOT NULL',
$this->bigInteger()->notNull(),
'bigint NOT NULL'
],
[
Schema::TYPE_FLOAT,
$this->float(),
'float'
],
[
Schema::TYPE_FLOAT . '(16)',
$this->float(16),
'float'
],
[
Schema::TYPE_FLOAT . ' CHECK (value > 5.6)',
$this->float()->check('value > 5.6'),
'float CHECK (value > 5.6)'
],
[
Schema::TYPE_FLOAT . '(16) CHECK (value > 5.6)',
$this->float(16)->check('value > 5.6'),
'float CHECK (value > 5.6)'
],
[
Schema::TYPE_FLOAT . ' NOT NULL',
$this->float()->notNull(),
'float NOT NULL'
],
[
Schema::TYPE_DOUBLE,
$this->double(),
'double'
],
[
Schema::TYPE_DOUBLE . '(16)',
$this->double(16),
'double'
],
[
Schema::TYPE_DOUBLE . ' CHECK (value > 5.6)',
$this->double()->check('value > 5.6'),
'double CHECK (value > 5.6)'
],
[
Schema::TYPE_DOUBLE . '(16) CHECK (value > 5.6)',
$this->double(16)->check('value > 5.6'),
'double CHECK (value > 5.6)'
],
[
Schema::TYPE_DOUBLE . ' NOT NULL',
$this->double()->notNull(),
'double NOT NULL'
],
[
Schema::TYPE_DECIMAL,
$this->decimal(),
'decimal(10,0)'
],
[
Schema::TYPE_DECIMAL . '(12,4)',
$this->decimal(12, 4),
'decimal(12,4)'
],
[
Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)',
$this->decimal()->check('value > 5.6'),
'decimal(10,0) CHECK (value > 5.6)'
],
[
Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)',
$this->decimal(12, 4)->check('value > 5.6'),
'decimal(12,4) CHECK (value > 5.6)'
],
[
Schema::TYPE_DECIMAL . ' NOT NULL',
$this->decimal()->notNull(),
'decimal(10,0) NOT NULL'
],
[
Schema::TYPE_DATETIME,
$this->dateTime(),
'datetime'
],
[
Schema::TYPE_DATETIME . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')",
$this->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',
$this->dateTime()->notNull(),
'datetime NOT NULL'
],
[
Schema::TYPE_TIMESTAMP,
$this->timestamp(),
'timestamp'
],
[
Schema::TYPE_TIMESTAMP . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')",
$this->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',
$this->timestamp()->notNull(),
'timestamp NOT NULL'
],
[
Schema::TYPE_TIME,
$this->time(),
'time'
],
[
Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')",
$this->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',
$this->time()->notNull(),
'time NOT NULL'
],
[
Schema::TYPE_DATE,
$this->date(),
'date'
],
[
Schema::TYPE_DATE . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')",
$this->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',
$this->date()->notNull(),
'date NOT NULL'
],
[
Schema::TYPE_BINARY,
$this->binary(),
'blob'
],
[
Schema::TYPE_BOOLEAN,
$this->boolean(),
'boolean'
],
[
Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1',
$this->boolean()->notNull()->defaultValue(1),
'boolean NOT NULL DEFAULT 1'
],
[
Schema::TYPE_MONEY,
$this->money(),
'decimal(19,4)'
],
[
Schema::TYPE_MONEY . '(16,2)',
$this->money(16, 2),
'decimal(16,2)'
],
[
Schema::TYPE_MONEY . ' CHECK (value > 0.0)',
$this->money()->check('value > 0.0'),
'decimal(19,4) CHECK (value > 0.0)'
],
[
Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)',
$this->money(16, 2)->check('value > 0.0'),
'decimal(16,2) CHECK (value > 0.0)'
],
[
Schema::TYPE_MONEY . ' NOT NULL',
$this->money()->notNull(),
'decimal(19,4) NOT NULL'
],
];
}

Loading…
Cancel
Save