added more types to pgsql schema, better detection

fixes #3578
This commit is contained in:
Carsten Brandt
2014-05-25 10:21:23 +02:00
parent c11ca0873d
commit 6fd25815ba
2 changed files with 60 additions and 25 deletions

View File

@@ -26,49 +26,83 @@ class Schema extends \yii\db\Schema
/**
* @var array mapping from physical column types (keys) to abstract
* column types (values)
* @see http://www.postgresql.org/docs/current/static/datatype.html#DATATYPE-TABLE
*/
public $typeMap = [
'abstime' => self::TYPE_TIMESTAMP,
'bit' => self::TYPE_STRING,
'bit varying' => self::TYPE_STRING,
'varbit' => self::TYPE_STRING,
'bool' => self::TYPE_BOOLEAN,
'boolean' => self::TYPE_BOOLEAN,
'box' => self::TYPE_STRING,
'character' => self::TYPE_STRING,
'bytea' => self::TYPE_BINARY,
'char' => self::TYPE_STRING,
'cidr' => self::TYPE_STRING,
'circle' => self::TYPE_STRING,
'date' => self::TYPE_DATE,
'real' => self::TYPE_FLOAT,
'decimal' => self::TYPE_DECIMAL,
'double precision' => self::TYPE_DECIMAL,
'point' => self::TYPE_STRING,
'line' => self::TYPE_STRING,
'lseg' => self::TYPE_STRING,
'polygon' => self::TYPE_STRING,
'path' => self::TYPE_STRING,
'character' => self::TYPE_STRING,
'char' => self::TYPE_STRING,
'character varying' => self::TYPE_STRING,
'varchar' => self::TYPE_STRING,
'text' => self::TYPE_TEXT,
'bytea' => self::TYPE_BINARY,
'cidr' => self::TYPE_STRING,
'inet' => self::TYPE_STRING,
'macaddr' => self::TYPE_STRING,
'real' => self::TYPE_FLOAT,
'float4' => self::TYPE_FLOAT,
'double precision' => self::TYPE_FLOAT,
'float8' => self::TYPE_FLOAT,
'decimal' => self::TYPE_DECIMAL,
'numeric' => self::TYPE_DECIMAL,
'money' => self::TYPE_MONEY,
'smallint' => self::TYPE_SMALLINT,
'int2' => self::TYPE_INTEGER,
'int2' => self::TYPE_SMALLINT,
'int4' => self::TYPE_INTEGER,
'int8' => self::TYPE_BIGINT,
'int' => self::TYPE_INTEGER,
'integer' => self::TYPE_INTEGER,
'bigint' => self::TYPE_BIGINT,
'interval' => self::TYPE_STRING,
'json' => self::TYPE_STRING,
'line' => self::TYPE_STRING,
'macaddr' => self::TYPE_STRING,
'money' => self::TYPE_MONEY,
'name' => self::TYPE_STRING,
'numeric' => self::TYPE_STRING,
'int8' => self::TYPE_BIGINT,
'oid' => self::TYPE_BIGINT, // should not be used. it's pg internal!
'path' => self::TYPE_STRING,
'point' => self::TYPE_STRING,
'polygon' => self::TYPE_STRING,
'text' => self::TYPE_TEXT,
'smallserial' => self::TYPE_SMALLINT,
'serial2' => self::TYPE_SMALLINT,
'serial4' => self::TYPE_INTEGER,
'serial' => self::TYPE_INTEGER,
'bigserial' => self::TYPE_BIGINT,
'serial8' => self::TYPE_BIGINT,
'pg_lsn' => self::TYPE_BIGINT,
'date' => self::TYPE_DATE,
'interval' => self::TYPE_STRING,
'time without time zone' => self::TYPE_TIME,
'time' => self::TYPE_TIME,
'time with time zone' => self::TYPE_TIME,
'timetz' => self::TYPE_TIME,
'timestamp without time zone' => self::TYPE_TIMESTAMP,
'timestamp' => self::TYPE_TIMESTAMP,
'timestamp with time zone' => self::TYPE_TIMESTAMP,
'time with time zone' => self::TYPE_TIMESTAMP,
'timestamptz' => self::TYPE_TIMESTAMP,
'abstime' => self::TYPE_TIMESTAMP,
'tsquery' => self::TYPE_STRING,
'tsvector' => self::TYPE_STRING,
'txid_snapshot' => self::TYPE_STRING,
'unknown' => self::TYPE_STRING,
'uuid' => self::TYPE_STRING,
'bit varying' => self::TYPE_STRING,
'character varying' => self::TYPE_STRING,
'json' => self::TYPE_STRING,
'jsonb' => self::TYPE_STRING,
'xml' => self::TYPE_STRING
];