diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index a89d1d85dc..b776c2339d 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -32,6 +32,7 @@ Yii Framework 2 Change Log - Bug #3548: Fixed the bug that X-Rate-Limit-Remaining header is always zero when using RateLimiter (qiangxue) - Bug #3564: Fixed the bug that primary key columns should not take default values from schema (qiangxue) - Bug #3567: Fixed the bug that smallint was treated as string for PostgreSQL (qiangxue) +- Bug #3578: Fixed postgreSQL column type detection, added missing types (MDMunir, cebe) - Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark) - Enh #2264: `CookieCollection::has()` will return false for expired or removed cookies (qiangxue) - Enh #2435: `yii\db\IntegrityException` is now thrown on database integrity errors instead of general `yii\db\Exception` (samdark) diff --git a/framework/db/pgsql/Schema.php b/framework/db/pgsql/Schema.php index ca17526016..46d545dab6 100644 --- a/framework/db/pgsql/Schema.php +++ b/framework/db/pgsql/Schema.php @@ -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 ];