Adds char datatype to framework

This commit is contained in:
Chris Harris
2016-02-20 01:52:23 -08:00
parent eaa00b6fd9
commit eaeb926768
22 changed files with 1718 additions and 331 deletions

View File

@@ -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'
],
];
}