Unverified Commit 42dfc79a authored by Benjamin Morel's avatar Benjamin Morel Committed by Sergei Morozov

Drop Drizzle support

parent 0e41252e
......@@ -103,6 +103,10 @@ After:
$stmt->bindValue(1, 1, ParameterType::INTEGER);
$stmt->fetchAll(FetchMode::COLUMN);
## BC BREAK: Removed Drizzle support
The Drizzle project is abandoned and is therefore not supported by Doctrine DBAL anymore.
## BC BREAK: Removed dbal:import CLI command
The `dbal:import` CLI command has been removed since it only worked with PDO-based drivers by relying on a non-documented behavior of the extension, and it was impossible to make it work with other drivers.
......
......@@ -71,12 +71,8 @@ full driver name::
pdo-mysql://localhost:4486/foo?charset=UTF-8
If you wanted to use the ``drizzle_pdo__mysql`` driver instead::
drizzle-pdo-mysql://localhost:4486/foo?charset=UTF-8
In the last two examples above, mind the dashes instead of the
underscores in the URL schemes.
In the example above, mind the dashes instead of the
underscores in the URL scheme.
For connecting to an SQLite database, the authority portion of the
URL is obviously irrelevant and thus can be omitted. The path part
......@@ -126,8 +122,6 @@ interfaces to use. It can be configured in one of three ways:
- ``pdo_mysql``: A MySQL driver that uses the pdo_mysql PDO
extension.
- ``drizzle_pdo_mysql``: A Drizzle driver that uses pdo_mysql PDO
extension.
- ``mysqli``: A MySQL driver that uses the mysqli extension.
- ``pdo_sqlite``: An SQLite driver that uses the pdo_sqlite PDO
extension.
......@@ -195,23 +189,6 @@ pdo_mysql
- ``charset`` (string): The charset used when connecting to the
database.
drizzle_pdo_mysql
^^^^^^^^^^^^^^^^^
**Requires** drizzle plugin ``mysql_protocol`` or ``mysql_unix_socket_protocol`` to be enabled.
On Ubuntu this can be done by editing ``/etc/drizzle/conf.d/mysql-protocol.cnf``
or ``/etc/drizzle/conf.d/mysql-unix-socket-protocol.cnf`` and restarting the drizzled daemon.
- ``user`` (string): Username to use when connecting to the
database. Only needed if authentication is configured for drizzled.
- ``password`` (string): Password to use when connecting to the
database. Only needed if authentication is configured for drizzled.
- ``host`` (string): Hostname of the database to connect to.
- ``port`` (integer): Port of the database to connect to.
- ``dbname`` (string): Name of the database/schema to connect to.
- ``unix_socket`` (string): Name of the socket used to connect to
the database.
mysqli
^^^^^^
......@@ -374,7 +351,7 @@ You can also pass this option if you want to disable automatic database platform
detection for a driver that natively supports it and choose the platform version
implementation explicitly.
If you are running a MariaDB database, you should prefix the ``serverVersion``
If you are running a MariaDB database, you should prefix the ``serverVersion``
with ``mariadb-`` (ex: ``mariadb-10.2.12``).
Custom Platform
......
......@@ -21,7 +21,6 @@ The following database vendors are currently supported:
- PostgreSQL
- SAP Sybase SQL Anywhere
- SQLite
- Drizzle
The Doctrine 2 database layer can be used independently of the
object-relational mapper. In order to use the DBAL all you need is
......
......@@ -70,11 +70,6 @@ SQLite
- ``SqlitePlatform`` for all versions.
Drizzle
^^^^^^
- ``DrizzlePlatform`` for all versions (deprecated).
It is highly encouraged to use the platform class that matches your
database vendor and version best. Otherwise it is not guaranteed
that the compatibility in terms of SQL dialect and feature support
......
......@@ -116,10 +116,10 @@ The following options are not completely portable but are supported by most of t
vendors:
- **unsigned** (boolean): Whether a ``smallint``, ``integer`` or ``bigint`` Doctrine
type column should allow unsigned values only. Supported by MySQL, SQL Anywhere
and Drizzle. Defaults to ``false``.
type column should allow unsigned values only. Supported by MySQL and SQL Anywhere.
Defaults to ``false``.
- **comment** (integer|string): The column comment. Supported by MySQL, PostgreSQL,
Oracle, SQL Server, SQL Anywhere and Drizzle. Defaults to ``null``.
Oracle, SQL Server and SQL Anywhere. Defaults to ``null``.
Vendor specific options
^^^^^^^^^^^^^^^^^^^^^^^
......@@ -134,8 +134,8 @@ The following options are completely vendor specific and absolutely not portable
supported by some vendors but not portable:
- **charset** (string): The character set to use for the column. Currently only supported
on MySQL and Drizzle.
on MySQL.
- **collation** (string): The collation to use for the column. Supported by MySQL, PostgreSQL,
Sqlite, SQL Server and Drizzle.
Sqlite and SQL Server.
- **check** (string): The check constraint clause to add to the column.
Defaults to ``null``.
......@@ -517,8 +517,6 @@ Please also notice the mapping specific footnotes for additional information.
+===================+===============+==========================+=========+==========================================================+
| **smallint** | ``integer`` | **MySQL** | *all* | ``SMALLINT`` ``UNSIGNED`` [10]_ ``AUTO_INCREMENT`` [11]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Drizzle** | *all* | ``INT`` ``UNSIGNED`` [10]_ ``AUTO_INCREMENT`` [11]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``SMALLINT`` |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``NUMBER(5)`` |
......@@ -527,11 +525,9 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Anywhere** | *all* | ``UNSIGNED`` [10]_ ``SMALLINT`` ``IDENTITY`` [11]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQLite** | *all* | ``INTEGER`` [16]_ |
| | | **SQLite** | *all* | ``INTEGER`` [15]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **integer** | ``integer`` | **MySQL** | *all* | ``INT`` ``UNSIGNED`` [10]_ ``AUTO_INCREMENT`` [11]_ |
| | +--------------------------+ | |
| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``INT`` [12]_ |
| | | | +----------------------------------------------------------+
......@@ -543,12 +539,10 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Anywhere** | *all* | ``UNSIGNED`` [10]_ ``INT`` ``IDENTITY`` [11]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQLite** | *all* | ``INTEGER`` [16]_ |
| | | **SQLite** | *all* | ``INTEGER`` [15]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **bigint** | ``string`` | **MySQL** | *all* | ``BIGINT`` ``UNSIGNED`` [10]_ ``AUTO_INCREMENT`` [11]_ |
| | [8]_ +--------------------------+ | |
| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | [8]_ +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``BIGINT`` [12]_ |
| | | | +----------------------------------------------------------+
| | | | | ``BIGSERIAL`` [11]_ |
......@@ -559,7 +553,7 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Anywhere** | *all* | ``UNSIGNED`` [10]_ ``BIGINT`` ``IDENTITY`` [11]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQLite** | *all* | ``INTEGER`` [16]_ |
| | | **SQLite** | *all* | ``INTEGER`` [15]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **decimal** [7]_ | ``string`` | **MySQL** | *all* | ``NUMERIC(p, s)`` ``UNSIGNED`` [10]_ |
| | [9]_ +--------------------------+---------+----------------------------------------------------------+
......@@ -572,8 +566,6 @@ Please also notice the mapping specific footnotes for additional information.
| | | **SQL Anywhere** | | |
| | +--------------------------+ | |
| | | **SQLite** | | |
| | +--------------------------+ | |
| | | **Drizzle** | | |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **float** | ``float`` | **MySQL** | *all* | ``DOUBLE PRECISION`` ``UNSIGNED`` [10]_ |
| | +--------------------------+---------+----------------------------------------------------------+
......@@ -586,8 +578,6 @@ Please also notice the mapping specific footnotes for additional information.
| | | **SQL Anywhere** | | |
| | +--------------------------+ | |
| | | **SQLite** | | |
| | +--------------------------+ | |
| | | **Drizzle** | | |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **string** | ``string`` | **MySQL** | *all* | ``VARCHAR(n)`` [3]_ |
| [2]_ [5]_ | +--------------------------+ | |
......@@ -597,8 +587,6 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+ | |
| | | **SQLite** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Drizzle** | *all* | ``VARCHAR(n)`` |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``VARCHAR2(n)`` [3]_ |
| | | | +----------------------------------------------------------+
| | | | | ``CHAR(n)`` [4]_ |
......@@ -607,19 +595,17 @@ Please also notice the mapping specific footnotes for additional information.
| | | | +----------------------------------------------------------+
| | | | | ``NCHAR(n)`` [4]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **text** | ``string`` | **MySQL** | *all* | ``TINYTEXT`` [17]_ |
| **text** | ``string`` | **MySQL** | *all* | ``TINYTEXT`` [16]_ |
| | | | +----------------------------------------------------------+
| | | | | ``TEXT`` [18]_ |
| | | | | ``TEXT`` [17]_ |
| | | | +----------------------------------------------------------+
| | | | | ``MEDIUMTEXT`` [19]_ |
| | | | | ``MEDIUMTEXT`` [18]_ |
| | | | +----------------------------------------------------------+
| | | | | ``LONGTEXT`` [20]_ |
| | | | | ``LONGTEXT`` [19]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``TEXT`` |
| | +--------------------------+ | |
| | | **SQL Anywhere** | | |
| | +--------------------------+ | |
| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``CLOB`` |
| | +--------------------------+ | |
......@@ -632,8 +618,6 @@ Please also notice the mapping specific footnotes for additional information.
| | | **Oracle** | | |
| | +--------------------------+ | |
| | | **SQLite** | | |
| | +--------------------------+ | |
| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | *all* | ``UNIQUEIDENTIFIER`` |
| | +--------------------------+ | |
......@@ -647,27 +631,23 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+ | ``BINARY(n)`` [4]_ |
| | | **SQL Anywhere** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Drizzle** | *all* | ``VARBINARY(n)`` |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``RAW(n)`` |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``BYTEA`` [16]_ |
| | | **PostgreSQL** | *all* | ``BYTEA`` [15]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQLite** | *all* | ``BLOB`` [16]_ |
| | | **SQLite** | *all* | ``BLOB`` [15]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **blob** | ``resource`` | **MySQL** | *all* | ``TINYBLOB`` [17]_ |
| **blob** | ``resource`` | **MySQL** | *all* | ``TINYBLOB`` [16]_ |
| | | | +----------------------------------------------------------+
| | | | | ``BLOB`` [18]_ |
| | | | | ``BLOB`` [17]_ |
| | | | +----------------------------------------------------------+
| | | | | ``MEDIUMBLOB`` [19]_ |
| | | | | ``MEDIUMBLOB`` [18]_ |
| | | | +----------------------------------------------------------+
| | | | | ``LONGBLOB`` [20]_ |
| | | | | ``LONGBLOB`` [19]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``BLOB`` |
| | +--------------------------+ | |
| | | **SQLite** | | |
| | +--------------------------+ | |
| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | *all* | ``VARBINARY(MAX)`` |
| | +--------------------------+---------+----------------------------------------------------------+
......@@ -680,8 +660,6 @@ Please also notice the mapping specific footnotes for additional information.
| | | **PostgreSQL** | *all* | ``BOOLEAN`` |
| | +--------------------------+ | |
| | | **SQLite** | | |
| | +--------------------------+ | |
| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | *all* | ``BIT`` |
| | +--------------------------+ | |
......@@ -698,14 +676,10 @@ Please also notice the mapping specific footnotes for additional information.
| | | **SQL Anywhere** | | |
| | +--------------------------+ | |
| | | **SQLite** | | |
| | +--------------------------+ | |
| | | **Drizzle** | | |
| | +--------------------------+---------+ |
| | | **SQL Server** | "all" | |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **datetime** | ``\DateTime`` | **MySQL** | *all* | ``DATETIME`` [13]_ |
| | +--------------------------+ +----------------------------------------------------------+
| | | **Drizzle** | | ``TIMESTAMP`` [14]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | *all* | ``DATETIME`` |
| | +--------------------------+ | |
......@@ -717,9 +691,7 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``TIMESTAMP(0)`` |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **datetimetz** | ``\DateTime`` | **MySQL** | *all* | ``DATETIME`` [15]_ [16]_ |
| | +--------------------------+ | |
| | | **Drizzle** | | |
| **datetimetz** | ``\DateTime`` | **MySQL** | *all* | ``DATETIME`` [14]_ [15]_ |
| | +--------------------------+ | |
| | | **SQLite** | | |
| | +--------------------------+---------+ |
......@@ -736,28 +708,24 @@ Please also notice the mapping specific footnotes for additional information.
| | | **SQL Anywhere** | | |
| | +--------------------------+ | |
| | | **SQLite** | | |
| | +--------------------------+ | |
| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``TIME(0) WITHOUT TIME ZONE`` |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``DATE`` [16]_ |
| | | **Oracle** | *all* | ``DATE`` [15]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | "all" | ``TIME(0)`` |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **array** [1]_ | ``array`` | **MySQL** | *all* | ``TINYTEXT`` [17]_ |
| **array** [1]_ | ``array`` | **MySQL** | *all* | ``TINYTEXT`` [16]_ |
+-------------------+ | | +----------------------------------------------------------+
| **simple array** | | | | ``TEXT`` [18]_ |
| **simple array** | | | | ``TEXT`` [17]_ |
| [1]_ | | | +----------------------------------------------------------+
| | | | | ``MEDIUMTEXT`` [19]_ |
| | | | | ``MEDIUMTEXT`` [18]_ |
| | | | +----------------------------------------------------------+
| | | | | ``LONGTEXT`` [20]_ |
| | | | | ``LONGTEXT`` [19]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``TEXT`` |
| | +--------------------------+ | |
| | | **SQL Anywhere** | | |
| | +--------------------------+ | |
| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``CLOB`` |
| | +--------------------------+ | |
......@@ -765,23 +733,21 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | *all* | ``VARCHAR(MAX)`` |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **json_array** | ``array`` | **MySQL** [1]_ | *all* | ``TINYTEXT`` [17]_ |
| **json_array** | ``array`` | **MySQL** [1]_ | *all* | ``TINYTEXT`` [16]_ |
| | | | +----------------------------------------------------------+
| | | | | ``TEXT`` [18]_ |
| | | | | ``TEXT`` [17]_ |
| | | | +----------------------------------------------------------+
| | | | | ``MEDIUMTEXT`` [19]_ |
| | | | | ``MEDIUMTEXT`` [18]_ |
| | | | +----------------------------------------------------------+
| | | | | ``LONGTEXT`` [20]_ |
| | | | | ``LONGTEXT`` [19]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | < 9.4 | ``JSON`` |
| | | +---------+----------------------------------------------------------+
| | | | >= 9.4 | ``JSON`` [21]_ |
| | | | >= 9.4 | ``JSON`` [20]_ |
| | | | +----------------------------------------------------------+
| | | | | ``JSONB`` [22]_ |
| | | | | ``JSONB`` [21]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Anywhere** | *all* | ``TEXT`` [1]_ |
| | +--------------------------+ | |
| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``CLOB`` [1]_ |
| | +--------------------------+ | |
......@@ -789,19 +755,17 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQL Server** | *all* | ``VARCHAR(MAX)`` [1]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **object** [1]_ | ``object`` | **MySQL** | *all* | ``TINYTEXT`` [17]_ |
| **object** [1]_ | ``object`` | **MySQL** | *all* | ``TINYTEXT`` [16]_ |
| | | | +----------------------------------------------------------+
| | | | | ``TEXT`` [18]_ |
| | | | | ``TEXT`` [17]_ |
| | | | +----------------------------------------------------------+
| | | | | ``MEDIUMTEXT`` [19]_ |
| | | | | ``MEDIUMTEXT`` [18]_ |
| | | | +----------------------------------------------------------+
| | | | | ``LONGTEXT`` [20]_ |
| | | | | ``LONGTEXT`` [19]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``TEXT`` |
| | +--------------------------+ | |
| | | **SQL Anywhere** | | |
| | +--------------------------+ | |
| | | **Drizzle** | | |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **Oracle** | *all* | ``CLOB`` |
| | +--------------------------+ | |
......@@ -817,10 +781,10 @@ Please also notice the mapping specific footnotes for additional information.
.. [4] Chosen if the column definition has the **fixed** attribute set to ``true``.
.. [5] Silently maps to the vendor specific ``text`` type if the given **length** attribute for
**n** exceeds the maximum length the related platform allows. If this is the case, please
see [16]_.
see [15]_.
.. [6] Silently maps to the vendor specific ``blob`` type if the given **length** attribute for
**n** exceeds the maximum length the related platform allows. If this is the case, please
see [16]_.
see [15]_.
.. [7] **p** is the precision and **s** the scale set in the column definition.
The precision defaults to ``10`` and the scale to ``0`` if not set.
.. [8] Returns PHP ``string`` type value instead of ``integer`` because of maximum integer value
......@@ -832,22 +796,20 @@ Please also notice the mapping specific footnotes for additional information.
.. [12] Chosen if the column definition has the **autoincrement** attribute set to ``false`` (default).
.. [13] Chosen if the column definition does not contain the **version** option inside the **platformOptions**
attribute array or is set to ``false`` which marks it as a non-locking information column.
.. [14] Chosen if the column definition contains the **version** option inside the **platformOptions**
attribute array and is set to ``true`` which marks it as a locking information column.
.. [15] Fallback type as the vendor does not support a native date time type with timezone information.
.. [14] Fallback type as the vendor does not support a native date time type with timezone information.
This means that the timezone information gets lost when storing a value.
.. [16] Cannot be safely reverse engineered to the same Doctrine type as the vendor does not have a
.. [15] Cannot be safely reverse engineered to the same Doctrine type as the vendor does not have a
native distinct data type for this mapping. Using this type with this vendor can therefore
have implications on schema comparison (*online* vs *offline* schema) and PHP type safety
(data conversion from database to PHP value) because it silently falls back to its
appropriate Doctrine type.
.. [17] Chosen if the column length is less or equal to **2 ^ 8 - 1 = 255**.
.. [18] Chosen if the column length is less or equal to **2 ^ 16 - 1 = 65535**.
.. [19] Chosen if the column length is less or equal to **2 ^ 24 - 1 = 16777215**.
.. [20] Chosen if the column length is less or equal to **2 ^ 32 - 1 = 4294967295** or empty.
.. [21] Chosen if the column definition does not contain the **jsonb** option inside the **platformOptions**
.. [16] Chosen if the column length is less or equal to **2 ^ 8 - 1 = 255**.
.. [17] Chosen if the column length is less or equal to **2 ^ 16 - 1 = 65535**.
.. [18] Chosen if the column length is less or equal to **2 ^ 24 - 1 = 16777215**.
.. [19] Chosen if the column length is less or equal to **2 ^ 32 - 1 = 4294967295** or empty.
.. [20] Chosen if the column definition does not contain the **jsonb** option inside the **platformOptions**
attribute array or is set to ``false``.
.. [22] Chosen if the column definition contains the **jsonb** option inside the **platformOptions**
.. [21] Chosen if the column definition contains the **jsonb** option inside the **platformOptions**
attribute array and is set to ``true``.
Detection of Database Types
......
<?php
namespace Doctrine\DBAL\Driver\DrizzlePDOMySql;
use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\ParameterType;
/**
* @deprecated
*/
class Connection extends PDOConnection
{
/**
* {@inheritdoc}
*/
public function quote($value, $type = ParameterType::STRING)
{
if ($type === ParameterType::BOOLEAN) {
return $value ? 'true' : 'false';
}
return parent::quote($value, $type);
}
}
<?php
namespace Doctrine\DBAL\Driver\DrizzlePDOMySql;
use Doctrine\DBAL\Platforms\DrizzlePlatform;
use Doctrine\DBAL\Schema\DrizzleSchemaManager;
/**
* Drizzle driver using PDO MySql.
*
* @deprecated
*/
class Driver extends \Doctrine\DBAL\Driver\PDOMySql\Driver
{
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
return new Connection(
$this->constructPdoDsn($params),
$username,
$password,
$driverOptions
);
}
/**
* {@inheritdoc}
*/
public function createDatabasePlatformForVersion($version)
{
return $this->getDatabasePlatform();
}
/**
* {@inheritdoc}
*/
public function getDatabasePlatform()
{
return new DrizzlePlatform();
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{
return new DrizzleSchemaManager($conn);
}
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'drizzle_pdo_mysql';
}
}
......@@ -3,7 +3,6 @@
namespace Doctrine\DBAL;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver as DrizzlePDOMySQLDriver;
use Doctrine\DBAL\Driver\IBMDB2\DB2Driver;
use Doctrine\DBAL\Driver\Mysqli\Driver as MySQLiDriver;
use Doctrine\DBAL\Driver\OCI8\Driver as OCI8Driver;
......@@ -51,7 +50,6 @@ final class DriverManager
'ibm_db2' => DB2Driver::class,
'pdo_sqlsrv' => PDOSQLSrvDriver::class,
'mysqli' => MySQLiDriver::class,
'drizzle_pdo_mysql' => DrizzlePDOMySQLDriver::class,
'sqlanywhere' => SQLAnywhereDriver::class,
'sqlsrv' => SQLSrvDriver::class,
];
......
<?php
namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\BinaryType;
use InvalidArgumentException;
use function array_merge;
use function array_unique;
use function array_values;
use function count;
use function func_get_args;
use function implode;
use function is_array;
use function is_bool;
use function is_numeric;
use function is_string;
use function sprintf;
use function trim;
/**
* Drizzle platform
*
* @deprecated
*/
class DrizzlePlatform extends AbstractPlatform
{
/**
* {@inheritDoc}
*/
public function getName()
{
return 'drizzle';
}
/**
* {@inheritDoc}
*/
public function getIdentifierQuoteCharacter()
{
return '`';
}
/**
* {@inheritDoc}
*/
public function getConcatExpression()
{
return 'CONCAT(' . implode(', ', func_get_args()) . ')';
}
/**
* {@inheritdoc}
*/
protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit)
{
$function = $operator === '+' ? 'DATE_ADD' : 'DATE_SUB';
return $function . '(' . $date . ', INTERVAL ' . $interval . ' ' . $unit . ')';
}
/**
* {@inheritDoc}
*/
public function getDateDiffExpression($date1, $date2)
{
return 'DATEDIFF(' . $date1 . ', ' . $date2 . ')';
}
/**
* {@inheritDoc}
*/
public function getBooleanTypeDeclarationSQL(array $field)
{
return 'BOOLEAN';
}
/**
* {@inheritDoc}
*/
public function getIntegerTypeDeclarationSQL(array $field)
{
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
}
/**
* {@inheritDoc}
*/
protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
{
$autoinc = '';
if (! empty($columnDef['autoincrement'])) {
$autoinc = ' AUTO_INCREMENT';
}
return $autoinc;
}
/**
* {@inheritDoc}
*/
public function getBigIntTypeDeclarationSQL(array $field)
{
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
}
/**
* {@inheritDoc}
*/
public function getSmallIntTypeDeclarationSQL(array $field)
{
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
}
/**
* {@inheritDoc}
*/
protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed)
{
return $length ? 'VARCHAR(' . $length . ')' : 'VARCHAR(255)';
}
/**
* {@inheritdoc}
*/
protected function getBinaryTypeDeclarationSQLSnippet($length, $fixed)
{
return 'VARBINARY(' . ($length ?: 255) . ')';
}
/**
* {@inheritDoc}
*/
protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = [
'boolean' => 'boolean',
'varchar' => 'string',
'varbinary' => 'binary',
'integer' => 'integer',
'blob' => 'blob',
'decimal' => 'decimal',
'datetime' => 'datetime',
'date' => 'date',
'time' => 'time',
'text' => 'text',
'timestamp' => 'datetime',
'double' => 'float',
'bigint' => 'bigint',
];
}
/**
* {@inheritDoc}
*/
public function getClobTypeDeclarationSQL(array $field)
{
return 'TEXT';
}
/**
* {@inheritDoc}
*/
public function getBlobTypeDeclarationSQL(array $field)
{
return 'BLOB';
}
/**
* {@inheritDoc}
*/
public function getCreateDatabaseSQL($name)
{
return 'CREATE DATABASE ' . $name;
}
/**
* {@inheritDoc}
*/
public function getDropDatabaseSQL($name)
{
return 'DROP DATABASE ' . $name;
}
/**
* {@inheritDoc}
*/
protected function _getCreateTableSQL($tableName, array $columns, array $options = [])
{
$queryFields = $this->getColumnDeclarationListSQL($columns);
if (isset($options['uniqueConstraints']) && ! empty($options['uniqueConstraints'])) {
foreach ($options['uniqueConstraints'] as $index => $definition) {
$queryFields .= ', ' . $this->getUniqueConstraintDeclarationSQL($index, $definition);
}
}
// add all indexes
if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach ($options['indexes'] as $index => $definition) {
$queryFields .= ', ' . $this->getIndexDeclarationSQL($index, $definition);
}
}
// attach all primary keys
if (isset($options['primary']) && ! empty($options['primary'])) {
$keyColumns = array_unique(array_values($options['primary']));
$queryFields .= ', PRIMARY KEY(' . implode(', ', $keyColumns) . ')';
}
$query = 'CREATE ';
if (! empty($options['temporary'])) {
$query .= 'TEMPORARY ';
}
$query .= 'TABLE ' . $tableName . ' (' . $queryFields . ') ';
$query .= $this->buildTableOptions($options);
$query .= $this->buildPartitionOptions($options);
$sql = [$query];
if (isset($options['foreignKeys'])) {
foreach ((array) $options['foreignKeys'] as $definition) {
$sql[] = $this->getCreateForeignKeySQL($definition, $tableName);
}
}
return $sql;
}
/**
* Build SQL for table options
*
* @param mixed[] $options
*
* @return string
*/
private function buildTableOptions(array $options)
{
if (isset($options['table_options'])) {
return $options['table_options'];
}
$tableOptions = [];
// Collate
if (! isset($options['collate'])) {
$options['collate'] = 'utf8_unicode_ci';
}
$tableOptions[] = sprintf('COLLATE %s', $options['collate']);
// Engine
if (! isset($options['engine'])) {
$options['engine'] = 'InnoDB';
}
$tableOptions[] = sprintf('ENGINE = %s', $options['engine']);
// Auto increment
if (isset($options['auto_increment'])) {
$tableOptions[] = sprintf('AUTO_INCREMENT = %s', $options['auto_increment']);
}
// Comment
if (isset($options['comment'])) {
$comment = trim($options['comment'], " '");
$tableOptions[] = sprintf('COMMENT = %s ', $this->quoteStringLiteral($comment));
}
// Row format
if (isset($options['row_format'])) {
$tableOptions[] = sprintf('ROW_FORMAT = %s', $options['row_format']);
}
return implode(' ', $tableOptions);
}
/**
* Build SQL for partition options.
*
* @param mixed[] $options
*
* @return string
*/
private function buildPartitionOptions(array $options)
{
return isset($options['partition_options'])
? ' ' . $options['partition_options']
: '';
}
/**
* {@inheritDoc}
*/
public function getListDatabasesSQL()
{
return "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE CATALOG_NAME='LOCAL'";
}
/**
* {@inheritDoc}
*/
protected function getReservedKeywordsClass()
{
return Keywords\DrizzleKeywords::class;
}
/**
* {@inheritDoc}
*/
public function getListTablesSQL()
{
return "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE' AND TABLE_SCHEMA=DATABASE()";
}
/**
* {@inheritDoc}
*/
public function getListTableColumnsSQL($table, $database = null)
{
if ($database) {
$databaseSQL = $this->quoteStringLiteral($database);
} else {
$databaseSQL = 'DATABASE()';
}
return 'SELECT COLUMN_NAME, DATA_TYPE, COLUMN_COMMENT, IS_NULLABLE, IS_AUTO_INCREMENT, CHARACTER_MAXIMUM_LENGTH, COLUMN_DEFAULT,' .
' NUMERIC_PRECISION, NUMERIC_SCALE, COLLATION_NAME' .
' FROM DATA_DICTIONARY.COLUMNS' .
' WHERE TABLE_SCHEMA=' . $databaseSQL . ' AND TABLE_NAME = ' . $this->quoteStringLiteral($table);
}
/**
* {@inheritDoc}
*/
public function getListTableForeignKeysSQL($table, $database = null)
{
if ($database) {
$databaseSQL = $this->quoteStringLiteral($database);
} else {
$databaseSQL = 'DATABASE()';
}
return 'SELECT CONSTRAINT_NAME, CONSTRAINT_COLUMNS, REFERENCED_TABLE_NAME, REFERENCED_TABLE_COLUMNS, UPDATE_RULE, DELETE_RULE' .
' FROM DATA_DICTIONARY.FOREIGN_KEYS' .
' WHERE CONSTRAINT_SCHEMA=' . $databaseSQL . ' AND CONSTRAINT_TABLE=' . $this->quoteStringLiteral($table);
}
/**
* {@inheritDoc}
*/
public function getListTableIndexesSQL($table, $database = null)
{
if ($database) {
$databaseSQL = $this->quoteStringLiteral($database);
} else {
$databaseSQL = 'DATABASE()';
}
return "SELECT INDEX_NAME AS 'key_name', COLUMN_NAME AS 'column_name', IS_USED_IN_PRIMARY AS 'primary', IS_UNIQUE=0 AS 'non_unique'" .
' FROM DATA_DICTIONARY.INDEX_PARTS' .
' WHERE TABLE_SCHEMA=' . $databaseSQL . ' AND TABLE_NAME=' . $this->quoteStringLiteral($table);
}
/**
* {@inheritDoc}
*/
public function prefersIdentityColumns()
{
return true;
}
/**
* {@inheritDoc}
*/
public function supportsIdentityColumns()
{
return true;
}
/**
* {@inheritDoc}
*/
public function supportsInlineColumnComments()
{
return true;
}
/**
* {@inheritDoc}
*/
public function supportsViews()
{
return false;
}
/**
* {@inheritdoc}
*/
public function supportsColumnCollation()
{
return true;
}
/**
* {@inheritDoc}
*/
public function getDropIndexSQL($index, $table = null)
{
if ($index instanceof Index) {
$indexName = $index->getQuotedName($this);
} elseif (is_string($index)) {
$indexName = $index;
} else {
throw new InvalidArgumentException('DrizzlePlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.');
}
if ($table instanceof Table) {
$table = $table->getQuotedName($this);
} elseif (! is_string($table)) {
throw new InvalidArgumentException('DrizzlePlatform::getDropIndexSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
}
if ($index instanceof Index && $index->isPrimary()) {
// drizzle primary keys are always named "PRIMARY",
// so we cannot use them in statements because of them being keyword.
return $this->getDropPrimaryKeySQL($table);
}
return 'DROP INDEX ' . $indexName . ' ON ' . $table;
}
/**
* {@inheritDoc}
*/
protected function getDropPrimaryKeySQL($table)
{
return 'ALTER TABLE ' . $table . ' DROP PRIMARY KEY';
}
/**
* {@inheritDoc}
*/
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
{
if (isset($fieldDeclaration['version']) && $fieldDeclaration['version'] === true) {
return 'TIMESTAMP';
}
return 'DATETIME';
}
/**
* {@inheritDoc}
*/
public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
{
return 'TIME';
}
/**
* {@inheritDoc}
*/
public function getDateTypeDeclarationSQL(array $fieldDeclaration)
{
return 'DATE';
}
/**
* {@inheritDoc}
*/
public function getAlterTableSQL(TableDiff $diff)
{
$columnSql = [];
$queryParts = [];
$newName = $diff->getNewName();
if ($newName !== false) {
$queryParts[] = 'RENAME TO ' . $newName->getQuotedName($this);
}
foreach ($diff->addedColumns as $column) {
if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) {
continue;
}
$columnArray = $column->toArray();
$columnArray['comment'] = $this->getColumnComment($column);
$queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
}
foreach ($diff->removedColumns as $column) {
if ($this->onSchemaAlterTableRemoveColumn($column, $diff, $columnSql)) {
continue;
}
$queryParts[] = 'DROP ' . $column->getQuotedName($this);
}
foreach ($diff->changedColumns as $columnDiff) {
if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) {
continue;
}
$column = $columnDiff->column;
$columnArray = $column->toArray();
// Do not generate column alteration clause if type is binary and only fixed property has changed.
// Drizzle only supports binary type columns with variable length.
// Avoids unnecessary table alteration statements.
if ($columnArray['type'] instanceof BinaryType &&
$columnDiff->hasChanged('fixed') &&
count($columnDiff->changedProperties) === 1
) {
continue;
}
$columnArray['comment'] = $this->getColumnComment($column);
$queryParts[] = 'CHANGE ' . ($columnDiff->getOldColumnName()->getQuotedName($this)) . ' '
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
}
foreach ($diff->renamedColumns as $oldColumnName => $column) {
if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $column, $diff, $columnSql)) {
continue;
}
$oldColumnName = new Identifier($oldColumnName);
$columnArray = $column->toArray();
$columnArray['comment'] = $this->getColumnComment($column);
$queryParts[] = 'CHANGE ' . $oldColumnName->getQuotedName($this) . ' '
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
}
$sql = [];
$tableSql = [];
if (! $this->onSchemaAlterTable($diff, $tableSql)) {
if (count($queryParts) > 0) {
$sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . implode(', ', $queryParts);
}
$sql = array_merge(
$this->getPreAlterTableIndexForeignKeySQL($diff),
$sql,
$this->getPostAlterTableIndexForeignKeySQL($diff)
);
}
return array_merge($sql, $tableSql, $columnSql);
}
/**
* {@inheritDoc}
*/
public function getDropTemporaryTableSQL($table)
{
if ($table instanceof Table) {
$table = $table->getQuotedName($this);
} elseif (! is_string($table)) {
throw new InvalidArgumentException('getDropTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
}
return 'DROP TEMPORARY TABLE ' . $table;
}
/**
* {@inheritDoc}
*/
public function convertBooleans($item)
{
if (is_array($item)) {
foreach ($item as $key => $value) {
if (! is_bool($value) && ! is_numeric($value)) {
continue;
}
$item[$key] = $value ? 'true' : 'false';
}
} elseif (is_bool($item) || is_numeric($item)) {
$item = $item ? 'true' : 'false';
}
return $item;
}
/**
* {@inheritDoc}
*/
public function getLocateExpression($str, $substr, $startPos = false)
{
if ($startPos === false) {
return 'LOCATE(' . $substr . ', ' . $str . ')';
}
return 'LOCATE(' . $substr . ', ' . $str . ', ' . $startPos . ')';
}
/**
* {@inheritDoc}
*
* @deprecated Use application-generated UUIDs instead
*/
public function getGuidExpression()
{
return 'UUID()';
}
/**
* {@inheritDoc}
*/
public function getRegexpExpression()
{
return 'RLIKE';
}
}
<?php
namespace Doctrine\DBAL\Platforms\Keywords;
/**
* Drizzle Keywordlist.
*/
class DrizzleKeywords extends KeywordList
{
/**
* {@inheritdoc}
*/
public function getName()
{
return 'drizzle';
}
/**
* {@inheritdoc}
*/
protected function getKeywords()
{
return [
'ABS',
'ALL',
'ALLOCATE',
'ALTER',
'AND',
'ANY',
'ARE',
'ARRAY',
'AS',
'ASENSITIVE',
'ASYMMETRIC',
'AT',
'ATOMIC',
'AUTHORIZATION',
'AVG',
'BEGIN',
'BETWEEN',
'BIGINT',
'BINARY',
'BLOB',
'BOOLEAN',
'BOTH',
'BY',
'CALL',
'CALLED',
'CARDINALITY',
'CASCADED',
'CASE',
'CAST',
'CEIL',
'CEILING',
'CHAR',
'CHARACTER',
'CHARACTER_LENGTH',
'CHAR_LENGTH',
'CHECK',
'CLOB',
'CLOSE',
'COALESCE',
'COLLATE',
'COLLECT',
'COLUMN',
'COMMIT',
'CONDITION',
'CONNECT',
'CONSTRAINT',
'CONVERT',
'CORR',
'CORRESPONDING',
'COUNT',
'COVAR_POP',
'COVAR_SAMP',
'CREATE',
'CROSS',
'CUBE',
'CUME_DIST',
'CURRENT',
'CURRENT_DATE',
'CURRENT_DEFAULT_TRANSFORM_GROUP',
'CURRENT_PATH',
'CURRENT_ROLE',
'CURRENT_TIME',
'CURRENT_TIMESTAMP',
'CURRENT_TRANSFORM_GROUP_FOR_TYPE',
'CURRENT_USER',
'CURSOR',
'CYCLE',
'DATE',
'DAY',
'DEALLOCATE',
'DEC',
'DECIMAL',
'DECLARE',
'DEFAULT',
'DELETE',
'DENSE_RANK',
'DEREF',
'DESCRIBE',
'DETERMINISTIC',
'DISCONNECT',
'DISTINCT',
'DOUBLE',
'DROP',
'DYNAMIC',
'EACH',
'ELEMENT',
'ELSE',
'END',
'ESCAPE',
'EVERY',
'EXCEPT',
'EXEC',
'EXECUTE',
'EXISTS',
'EXP',
'EXTERNAL',
'EXTRACT',
'FALSE',
'FETCH',
'FILTER',
'FLOAT',
'FLOOR',
'FOR',
'FOREIGN',
'FREE',
'FROM',
'FULL',
'FUNCTION',
'FUSION',
'GET',
'GLOBAL',
'GRANT',
'GROUP',
'GROUPING',
'HAVING',
'HOLD',
'HOUR',
'IDENTITY',
'IN',
'INDICATOR',
'INNER',
'INOUT',
'INSENSITIVE',
'INSERT',
'INT',
'INTEGER',
'INTERSECT',
'INTERSECTION',
'INTERVAL',
'INTO',
'IS',
'JOIN',
'LANGUAGE',
'LARGE',
'LATERAL',
'LEADING',
'LEFT',
'LIKE',
'LN',
'LOCAL',
'LOCALTIME',
'LOCALTIMESTAMP',
'LOWER',
'MATCH',
'MAX',
'MEMBER',
'MERGE',
'METHOD',
'MIN',
'MINUTE',
'MOD',
'MODIFIES',
'MODULE',
'MONTH',
'MULTISET',
'NATIONAL',
'NATURAL',
'NCHAR',
'NCLOB',
'NEW',
'NO',
'NONE',
'NORMALIZE',
'NOT',
'NULL_SYM',
'NULLIF',
'NUMERIC',
'OCTET_LENGTH',
'OF',
'OLD',
'ON',
'ONLY',
'OPEN',
'OR',
'ORDER',
'OUT',
'OUTER',
'OVER',
'OVERLAPS',
'OVERLAY',
'PARAMETER',
'PARTITION',
'PERCENTILE_CONT',
'PERCENTILE_DISC',
'PERCENT_RANK',
'POSITION',
'POWER',
'PRECISION',
'PREPARE',
'PRIMARY',
'PROCEDURE',
'RANGE',
'RANK',
'READS',
'REAL',
'RECURSIVE',
'REF',
'REFERENCES',
'REFERENCING',
'REGR_AVGX',
'REGR_AVGY',
'REGR_COUNT',
'REGR_INTERCEPT',
'REGR_R2',
'REGR_SLOPE',
'REGR_SXX',
'REGR_SXY',
'REGR_SYY',
'RELEASE',
'RESULT',
'RETURN',
'RETURNS',
'REVOKE',
'RIGHT',
'ROLLBACK',
'ROLLUP',
'ROW',
'ROWS',
'ROW_NUMBER',
'SAVEPOINT',
'SCOPE',
'SCROLL',
'SEARCH',
'SECOND',
'SELECT',
'SENSITIVE',
'SESSION_USER',
'SET',
'SIMILAR',
'SMALLINT',
'SOME',
'SPECIFIC',
'SPECIFICTYPE',
'SQL',
'SQLEXCEPTION',
'SQLSTATE',
'SQLWARNING',
'SQRT',
'START',
'STATIC',
'STDDEV_POP',
'STDDEV_SAMP',
'SUBMULTISET',
'SUBSTRING',
'SUM',
'SYMMETRIC',
'SYSTEM',
'SYSTEM_USER',
'TABLE',
'TABLESAMPLE',
'THEN',
'TIME',
'TIMESTAMP',
'TIMEZONE_HOUR',
'TIMEZONE_MINUTE',
'TO',
'TRAILING',
'TRANSLATE',
'TRANSLATION',
'TREAT',
'TRIGGER',
'TRIM',
'TRUE',
'UESCAPE',
'UNION',
'UNIQUE',
'UNKNOWN',
'UNNEST',
'UPDATE',
'UPPER',
'USER',
'USING',
'VALUE',
'VALUES',
'VARCHAR',
'VARYING',
'VAR_POP',
'VAR_SAMP',
'WHEN',
'WHENEVER',
'WHERE',
'WIDTH_BUCKET',
'WINDOW',
'WITH',
'WITHIN',
'WITHOUT',
'XML',
'XMLAGG',
'XMLATTRIBUTES',
'XMLBINARY',
'XMLCOMMENT',
'XMLCONCAT',
'XMLELEMENT',
'XMLFOREST',
'XMLNAMESPACES',
'XMLPARSE',
'XMLPI',
'XMLROOT',
'XMLSERIALIZE',
'YEAR',
];
}
}
......@@ -27,7 +27,6 @@ class Connection extends \Doctrine\DBAL\Connection
public const PORTABILITY_POSTGRESQL = 13;
public const PORTABILITY_SQLITE = 13;
public const PORTABILITY_OTHERVENDORS = 12;
public const PORTABILITY_DRIZZLE = 13;
public const PORTABILITY_SQLANYWHERE = 13;
public const PORTABILITY_SQLSRV = 13;
......@@ -52,8 +51,6 @@ class Connection extends \Doctrine\DBAL\Connection
$params['portability'] &= self::PORTABILITY_POSTGRESQL;
} elseif ($this->getDatabasePlatform()->getName() === 'sqlite') {
$params['portability'] &= self::PORTABILITY_SQLITE;
} elseif ($this->getDatabasePlatform()->getName() === 'drizzle') {
$params['portability'] &= self::PORTABILITY_DRIZZLE;
} elseif ($this->getDatabasePlatform()->getName() === 'sqlanywhere') {
$params['portability'] &= self::PORTABILITY_SQLANYWHERE;
} elseif ($this->getDatabasePlatform()->getName() === 'db2') {
......
<?php
namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Types\Type;
use function explode;
use function strtolower;
use function trim;
/**
* Schema manager for the Drizzle RDBMS.
*/
class DrizzleSchemaManager extends AbstractSchemaManager
{
/**
* {@inheritdoc}
*/
protected function _getPortableTableColumnDefinition($tableColumn)
{
$dbType = strtolower($tableColumn['DATA_TYPE']);
$type = $this->_platform->getDoctrineTypeMapping($dbType);
$type = $this->extractDoctrineTypeFromComment($tableColumn['COLUMN_COMMENT'], $type);
$tableColumn['COLUMN_COMMENT'] = $this->removeDoctrineTypeFromComment($tableColumn['COLUMN_COMMENT'], $type);
$options = [
'notnull' => ! (bool) $tableColumn['IS_NULLABLE'],
'length' => (int) $tableColumn['CHARACTER_MAXIMUM_LENGTH'],
'default' => $tableColumn['COLUMN_DEFAULT'] ?? null,
'autoincrement' => (bool) $tableColumn['IS_AUTO_INCREMENT'],
'scale' => (int) $tableColumn['NUMERIC_SCALE'],
'precision' => (int) $tableColumn['NUMERIC_PRECISION'],
'comment' => isset($tableColumn['COLUMN_COMMENT']) && $tableColumn['COLUMN_COMMENT'] !== ''
? $tableColumn['COLUMN_COMMENT']
: null,
];
$column = new Column($tableColumn['COLUMN_NAME'], Type::getType($type), $options);
if (! empty($tableColumn['COLLATION_NAME'])) {
$column->setPlatformOption('collation', $tableColumn['COLLATION_NAME']);
}
return $column;
}
/**
* {@inheritdoc}
*/
protected function _getPortableDatabaseDefinition($database)
{
return $database['SCHEMA_NAME'];
}
/**
* {@inheritdoc}
*/
protected function _getPortableTableDefinition($table)
{
return $table['TABLE_NAME'];
}
/**
* {@inheritdoc}
*/
public function _getPortableTableForeignKeyDefinition($tableForeignKey)
{
$columns = [];
foreach (explode(',', $tableForeignKey['CONSTRAINT_COLUMNS']) as $value) {
$columns[] = trim($value, ' `');
}
$refColumns = [];
foreach (explode(',', $tableForeignKey['REFERENCED_TABLE_COLUMNS']) as $value) {
$refColumns[] = trim($value, ' `');
}
return new ForeignKeyConstraint(
$columns,
$tableForeignKey['REFERENCED_TABLE_NAME'],
$refColumns,
$tableForeignKey['CONSTRAINT_NAME'],
[
'onUpdate' => $tableForeignKey['UPDATE_RULE'],
'onDelete' => $tableForeignKey['DELETE_RULE'],
]
);
}
/**
* {@inheritdoc}
*/
protected function _getPortableTableIndexesList($tableIndexes, $tableName = null)
{
$indexes = [];
foreach ($tableIndexes as $k) {
$k['primary'] = (bool) $k['primary'];
$indexes[] = $k;
}
return parent::_getPortableTableIndexesList($indexes, $tableName);
}
}
<?php
namespace Doctrine\Tests\DBAL\Driver\DrizzlePDOMySql;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\DrizzlePlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\DrizzleSchemaManager;
use Doctrine\Tests\DBAL\Driver\PDOMySql\DriverTest as PDOMySQLDriverTest;
class DriverTest extends PDOMySQLDriverTest
{
public function testReturnsName() : void
{
self::assertSame('drizzle_pdo_mysql', $this->driver->getName());
}
public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion() : void
{
$this->markTestSkipped('This test does not work on Drizzle as it is not version aware.');
}
protected function createDriver() : DriverInterface
{
return new Driver();
}
protected function createPlatform() : AbstractPlatform
{
return new DrizzlePlatform();
}
protected function createSchemaManager(Connection $connection) : AbstractSchemaManager
{
return new DrizzleSchemaManager($connection);
}
/**
* @return mixed[][]
*/
protected function getDatabasePlatformsForVersions() : array
{
return [
['foo', DrizzlePlatform::class],
['bar', DrizzlePlatform::class],
['baz', DrizzlePlatform::class],
];
}
}
......@@ -6,7 +6,6 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Connections\MasterSlaveConnection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver as DrizzlePDOMySqlDriver;
use Doctrine\DBAL\Driver\PDOMySql\Driver as PDOMySQLDriver;
use Doctrine\DBAL\Driver\PDOSqlite\Driver as PDOSqliteDriver;
use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver;
......@@ -308,17 +307,17 @@ class DriverManagerTest extends DbalTestCase
],
],
'simple URL with fallthrough scheme containing underscores fails' => [
'drizzle_pdo_mysql://foo:bar@localhost/baz',
'pdo_mysql://foo:bar@localhost/baz',
false,
],
'simple URL with fallthrough scheme containing dashes works' => [
'drizzle-pdo-mysql://foo:bar@localhost/baz',
'pdo-mysql://foo:bar@localhost/baz',
[
'user' => 'foo',
'password' => 'bar',
'host' => 'localhost',
'dbname' => 'baz',
'driver' => DrizzlePDOMySqlDriver::class,
'driver' => PDOMySQLDriver::class,
],
],
'simple URL with percent encoding' => [
......
......@@ -6,7 +6,6 @@ use Doctrine\DBAL\Driver\ExceptionConverterDriver;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\DrizzlePlatform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
......@@ -357,10 +356,6 @@ EOT
$this->markTestSkipped('Only skipped if platform is not sqlite');
}
if ($platform instanceof DrizzlePlatform) {
$this->markTestSkipped('Drizzle does not always support authentication');
}
if ($platform instanceof PostgreSqlPlatform && isset($params['password'])) {
$this->markTestSkipped('Does not work on Travis');
}
......
<?php
namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\BinaryType;
class DrizzleSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
public function testListTableWithBinary() : void
{
$tableName = 'test_binary_table';
$table = new Table($tableName);
$table->addColumn('id', 'integer');
$table->addColumn('column_varbinary', 'binary', []);
$table->addColumn('column_binary', 'binary', ['fixed' => true]);
$table->setPrimaryKey(['id']);
$this->schemaManager->createTable($table);
$table = $this->schemaManager->listTableDetails($tableName);
self::assertInstanceOf(BinaryType::class, $table->getColumn('column_varbinary')->getType());
self::assertFalse($table->getColumn('column_varbinary')->getFixed());
self::assertInstanceOf(BinaryType::class, $table->getColumn('column_binary')->getType());
self::assertFalse($table->getColumn('column_binary')->getFixed());
}
public function testColumnCollation() : void
{
$table = new Table('test_collation');
$table->addOption('collate', $collation = 'utf8_unicode_ci');
$table->addColumn('id', 'integer');
$table->addColumn('text', 'text');
$table->addColumn('foo', 'text')->setPlatformOption('collation', 'utf8_swedish_ci');
$table->addColumn('bar', 'text')->setPlatformOption('collation', 'utf8_general_ci');
$this->schemaManager->dropAndCreateTable($table);
$columns = $this->schemaManager->listTableColumns('test_collation');
self::assertArrayNotHasKey('collation', $columns['id']->getPlatformOptions());
self::assertEquals('utf8_unicode_ci', $columns['text']->getPlatformOption('collation'));
self::assertEquals('utf8_swedish_ci', $columns['foo']->getPlatformOption('collation'));
self::assertEquals('utf8_general_ci', $columns['bar']->getPlatformOption('collation'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment