Skip to content

Commit

Permalink
Merge pull request #6018 from phansys/types_constants
Browse files Browse the repository at this point in the history
Use constants for DBAL types
  • Loading branch information
greg0ire committed Apr 18, 2023
2 parents 1265f8c + 71a4a46 commit 9d601a1
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 156 deletions.
61 changes: 31 additions & 30 deletions src/Platforms/AbstractMySQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\TextType;
use Doctrine\DBAL\Types\Types;
use Doctrine\Deprecations\Deprecation;
use InvalidArgumentException;

Expand Down Expand Up @@ -1241,36 +1242,36 @@ public function getReadLockSQL()
protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = [
'bigint' => 'bigint',
'binary' => 'binary',
'blob' => 'blob',
'char' => 'string',
'date' => 'date',
'datetime' => 'datetime',
'decimal' => 'decimal',
'double' => 'float',
'float' => 'float',
'int' => 'integer',
'integer' => 'integer',
'longblob' => 'blob',
'longtext' => 'text',
'mediumblob' => 'blob',
'mediumint' => 'integer',
'mediumtext' => 'text',
'numeric' => 'decimal',
'real' => 'float',
'set' => 'simple_array',
'smallint' => 'smallint',
'string' => 'string',
'text' => 'text',
'time' => 'time',
'timestamp' => 'datetime',
'tinyblob' => 'blob',
'tinyint' => 'boolean',
'tinytext' => 'text',
'varbinary' => 'binary',
'varchar' => 'string',
'year' => 'date',
'bigint' => Types::BIGINT,
'binary' => Types::BINARY,
'blob' => Types::BLOB,
'char' => Types::STRING,
'date' => Types::DATE_MUTABLE,
'datetime' => Types::DATETIME_MUTABLE,
'decimal' => Types::DECIMAL,
'double' => Types::FLOAT,
'float' => Types::FLOAT,
'int' => Types::INTEGER,
'integer' => Types::INTEGER,
'longblob' => Types::BLOB,
'longtext' => Types::TEXT,
'mediumblob' => Types::BLOB,
'mediumint' => Types::INTEGER,
'mediumtext' => Types::TEXT,
'numeric' => Types::DECIMAL,
'real' => Types::FLOAT,
'set' => Types::SIMPLE_ARRAY,
'smallint' => Types::SMALLINT,
'string' => Types::STRING,
'text' => Types::TEXT,
'time' => Types::TIME_MUTABLE,
'timestamp' => Types::DATETIME_MUTABLE,
'tinyblob' => Types::BLOB,
'tinyint' => Types::BOOLEAN,
'tinytext' => Types::TEXT,
'varbinary' => Types::BINARY,
'varchar' => Types::STRING,
'year' => Types::DATE_MUTABLE,
];
}

Expand Down
47 changes: 24 additions & 23 deletions src/Platforms/OraclePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\BinaryType;
use Doctrine\DBAL\Types\Types;
use Doctrine\Deprecations\Deprecation;
use InvalidArgumentException;

Expand Down Expand Up @@ -1240,29 +1241,29 @@ public function getDummySelectSQL()
protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = [
'binary_double' => 'float',
'binary_float' => 'float',
'binary_integer' => 'boolean',
'blob' => 'blob',
'char' => 'string',
'clob' => 'text',
'date' => 'date',
'float' => 'float',
'integer' => 'integer',
'long' => 'string',
'long raw' => 'blob',
'nchar' => 'string',
'nclob' => 'text',
'number' => 'integer',
'nvarchar2' => 'string',
'pls_integer' => 'boolean',
'raw' => 'binary',
'rowid' => 'string',
'timestamp' => 'datetime',
'timestamptz' => 'datetimetz',
'urowid' => 'string',
'varchar' => 'string',
'varchar2' => 'string',
'binary_double' => Types::FLOAT,
'binary_float' => Types::FLOAT,
'binary_integer' => Types::BOOLEAN,
'blob' => Types::BLOB,
'char' => Types::STRING,
'clob' => Types::TEXT,
'date' => Types::DATE_MUTABLE,
'float' => Types::FLOAT,
'integer' => Types::INTEGER,
'long' => Types::STRING,
'long raw' => Types::BLOB,
'nchar' => Types::STRING,
'nclob' => Types::TEXT,
'number' => Types::INTEGER,
'nvarchar2' => Types::STRING,
'pls_integer' => Types::BOOLEAN,
'raw' => Types::BINARY,
'rowid' => Types::STRING,
'timestamp' => Types::DATETIME_MUTABLE,
'timestamptz' => Types::DATETIMETZ_MUTABLE,
'urowid' => Types::STRING,
'varchar' => Types::STRING,
'varchar2' => Types::STRING,
];
}

Expand Down
83 changes: 42 additions & 41 deletions src/Platforms/PostgreSQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\BinaryType;
use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\Types;
use Doctrine\Deprecations\Deprecation;
use UnexpectedValueException;

Expand Down Expand Up @@ -1166,47 +1167,47 @@ public function getReadLockSQL()
protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = [
'bigint' => 'bigint',
'bigserial' => 'bigint',
'bool' => 'boolean',
'boolean' => 'boolean',
'bpchar' => 'string',
'bytea' => 'blob',
'char' => 'string',
'date' => 'date',
'datetime' => 'datetime',
'decimal' => 'decimal',
'double' => 'float',
'double precision' => 'float',
'float' => 'float',
'float4' => 'float',
'float8' => 'float',
'inet' => 'string',
'int' => 'integer',
'int2' => 'smallint',
'int4' => 'integer',
'int8' => 'bigint',
'integer' => 'integer',
'interval' => 'string',
'json' => 'json',
'jsonb' => 'json',
'money' => 'decimal',
'numeric' => 'decimal',
'serial' => 'integer',
'serial4' => 'integer',
'serial8' => 'bigint',
'real' => 'float',
'smallint' => 'smallint',
'text' => 'text',
'time' => 'time',
'timestamp' => 'datetime',
'timestamptz' => 'datetimetz',
'timetz' => 'time',
'tsvector' => 'text',
'uuid' => 'guid',
'varchar' => 'string',
'year' => 'date',
'_varchar' => 'string',
'bigint' => Types::BIGINT,
'bigserial' => Types::BIGINT,
'bool' => Types::BOOLEAN,
'boolean' => Types::BOOLEAN,
'bpchar' => Types::STRING,
'bytea' => Types::BLOB,
'char' => Types::STRING,
'date' => Types::DATE_MUTABLE,
'datetime' => Types::DATETIME_MUTABLE,
'decimal' => Types::DECIMAL,
'double' => Types::FLOAT,
'double precision' => Types::FLOAT,
'float' => Types::FLOAT,
'float4' => Types::FLOAT,
'float8' => Types::FLOAT,
'inet' => Types::STRING,
'int' => Types::INTEGER,
'int2' => Types::SMALLINT,
'int4' => Types::INTEGER,
'int8' => Types::BIGINT,
'integer' => Types::INTEGER,
'interval' => Types::STRING,
'json' => Types::JSON,
'jsonb' => Types::JSON,
'money' => Types::DECIMAL,
'numeric' => Types::DECIMAL,
'serial' => Types::INTEGER,
'serial4' => Types::INTEGER,
'serial8' => Types::BIGINT,
'real' => Types::FLOAT,
'smallint' => Types::SMALLINT,
'text' => Types::TEXT,
'time' => Types::TIME_MUTABLE,
'timestamp' => Types::DATETIME_MUTABLE,
'timestamptz' => Types::DATETIMETZ_MUTABLE,
'timetz' => Types::TIME_MUTABLE,
'tsvector' => Types::TEXT,
'uuid' => Types::GUID,
'varchar' => Types::STRING,
'year' => Types::DATE_MUTABLE,
'_varchar' => Types::STRING,
];
}

Expand Down
61 changes: 31 additions & 30 deletions src/Platforms/SQLServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\DBAL\Schema\SQLServerSchemaManager;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\Types;
use Doctrine\Deprecations\Deprecation;
use InvalidArgumentException;

Expand Down Expand Up @@ -1517,36 +1518,36 @@ public function getName()
protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = [
'bigint' => 'bigint',
'binary' => 'binary',
'bit' => 'boolean',
'blob' => 'blob',
'char' => 'string',
'date' => 'date',
'datetime' => 'datetime',
'datetime2' => 'datetime',
'datetimeoffset' => 'datetimetz',
'decimal' => 'decimal',
'double' => 'float',
'double precision' => 'float',
'float' => 'float',
'image' => 'blob',
'int' => 'integer',
'money' => 'integer',
'nchar' => 'string',
'ntext' => 'text',
'numeric' => 'decimal',
'nvarchar' => 'string',
'real' => 'float',
'smalldatetime' => 'datetime',
'smallint' => 'smallint',
'smallmoney' => 'integer',
'text' => 'text',
'time' => 'time',
'tinyint' => 'smallint',
'uniqueidentifier' => 'guid',
'varbinary' => 'binary',
'varchar' => 'string',
'bigint' => Types::BIGINT,
'binary' => Types::BINARY,
'bit' => Types::BOOLEAN,
'blob' => Types::BLOB,
'char' => Types::STRING,
'date' => Types::DATE_MUTABLE,
'datetime' => Types::DATETIME_MUTABLE,
'datetime2' => Types::DATETIME_MUTABLE,
'datetimeoffset' => Types::DATETIMETZ_MUTABLE,
'decimal' => Types::DECIMAL,
'double' => Types::FLOAT,
'double precision' => Types::FLOAT,
'float' => Types::FLOAT,
'image' => Types::BLOB,
'int' => Types::INTEGER,
'money' => Types::INTEGER,
'nchar' => Types::STRING,
'ntext' => Types::TEXT,
'numeric' => Types::DECIMAL,
'nvarchar' => Types::STRING,
'real' => Types::FLOAT,
'smalldatetime' => Types::DATETIME_MUTABLE,
'smallint' => Types::SMALLINT,
'smallmoney' => Types::INTEGER,
'text' => Types::TEXT,
'time' => Types::TIME_MUTABLE,
'tinyint' => Types::SMALLINT,
'uniqueidentifier' => Types::GUID,
'varbinary' => Types::BINARY,
'varchar' => Types::STRING,
];
}

Expand Down
64 changes: 32 additions & 32 deletions src/Platforms/SqlitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -761,38 +761,38 @@ private function getInlineTableCommentSQL(string $comment): string
protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = [
'bigint' => 'bigint',
'bigserial' => 'bigint',
'blob' => 'blob',
'boolean' => 'boolean',
'char' => 'string',
'clob' => 'text',
'date' => 'date',
'datetime' => 'datetime',
'decimal' => 'decimal',
'double' => 'float',
'double precision' => 'float',
'float' => 'float',
'image' => 'string',
'int' => 'integer',
'integer' => 'integer',
'longtext' => 'text',
'longvarchar' => 'string',
'mediumint' => 'integer',
'mediumtext' => 'text',
'ntext' => 'string',
'numeric' => 'decimal',
'nvarchar' => 'string',
'real' => 'float',
'serial' => 'integer',
'smallint' => 'smallint',
'text' => 'text',
'time' => 'time',
'timestamp' => 'datetime',
'tinyint' => 'boolean',
'tinytext' => 'text',
'varchar' => 'string',
'varchar2' => 'string',
'bigint' => Types\Types::BIGINT,
'bigserial' => Types\Types::BIGINT,
'blob' => Types\Types::BLOB,
'boolean' => Types\Types::BOOLEAN,
'char' => Types\Types::STRING,
'clob' => Types\Types::TEXT,
'date' => Types\Types::DATE_MUTABLE,
'datetime' => Types\Types::DATETIME_MUTABLE,
'decimal' => Types\Types::DECIMAL,
'double' => Types\Types::FLOAT,
'double precision' => Types\Types::FLOAT,
'float' => Types\Types::FLOAT,
'image' => Types\Types::STRING,
'int' => Types\Types::INTEGER,
'integer' => Types\Types::INTEGER,
'longtext' => Types\Types::TEXT,
'longvarchar' => Types\Types::STRING,
'mediumint' => Types\Types::INTEGER,
'mediumtext' => Types\Types::TEXT,
'ntext' => Types\Types::STRING,
'numeric' => Types\Types::DECIMAL,
'nvarchar' => Types\Types::STRING,
'real' => Types\Types::FLOAT,
'serial' => Types\Types::INTEGER,
'smallint' => Types\Types::SMALLINT,
'text' => Types\Types::TEXT,
'time' => Types\Types::TIME_MUTABLE,
'timestamp' => Types\Types::DATETIME_MUTABLE,
'tinyint' => Types\Types::BOOLEAN,
'tinytext' => Types\Types::TEXT,
'varchar' => Types\Types::STRING,
'varchar2' => Types\Types::STRING,
];
}

Expand Down

0 comments on commit 9d601a1

Please sign in to comment.