Skip to content

Commit

Permalink
Merge branch '3.4.x' into 4.0.x
Browse files Browse the repository at this point in the history
* 3.4.x:
  doctrine#5339 Redact connection URL from logs as it may contain sensitive data (password)
  Update PHPStan to 1.5.3
  Mark DBAL 2 as no longer maintained
  Remove documentation bits only relevant to DBAL 2
  Leverage int-mask-of to make types more precise
  Support TEXT/BLOB default values on MariaDB
  • Loading branch information
derrabus committed Apr 5, 2022
2 parents e026335 + a5b9420 commit d2420a2
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 845 deletions.
3 changes: 1 addition & 2 deletions .doctrine-project.json
Expand Up @@ -35,9 +35,8 @@
},
{
"name": "2.13",
"branchName": "2.13.x",
"slug": "2.13",
"current": true
"maintained": false
},
{
"name": "2.12",
Expand Down
20 changes: 6 additions & 14 deletions README.md
@@ -1,11 +1,11 @@
# Doctrine DBAL

| [4.0-dev][4.0] | [3.3][3.3] | [2.13][2.13] |
|:----------------:|:----------:|:----------:|
| [![GitHub Actions][GA 4.0 image]][GA 4.0] | [![GitHub Actions][GA 3.3 image]][GA 3.3] | [![GitHub Actions][GA 2.13 image]][GA 2.13] |
| [![AppVeyor][AppVeyor 4.0 image]][AppVeyor 4.0] | [![AppVeyor][AppVeyor 3.3 image]][AppVeyor 3.3] | [![AppVeyor][AppVeyor 2.13 image]][AppVeyor 2.13] |
| [![Code Coverage][Coverage image]][CodeCov 4.0] | [![Code Coverage][Coverage 3.3 image]][CodeCov 3.3] | [![Code Coverage][Coverage 2.13 image]][CodeCov 2.13] |
| N/A | [![Code Coverage][TypeCov 3.3 image]][TypeCov 3.3] | N/A |
| [4.0-dev][4.0] | [3.3][3.3] |
|:-----------------------------------------------:|:---------------------------------------------------:|
| [![GitHub Actions][GA 4.0 image]][GA 4.0] | [![GitHub Actions][GA 3.3 image]][GA 3.3] |
| [![AppVeyor][AppVeyor 4.0 image]][AppVeyor 4.0] | [![AppVeyor][AppVeyor 3.3 image]][AppVeyor 3.3] |
| [![Code Coverage][Coverage image]][CodeCov 4.0] | [![Code Coverage][Coverage 3.3 image]][CodeCov 3.3] |
| N/A | [![Code Coverage][TypeCov 3.3 image]][TypeCov 3.3] |

Powerful ***D***ata***B***ase ***A***bstraction ***L***ayer with many features for database schema introspection and schema management.

Expand All @@ -32,11 +32,3 @@ Powerful ***D***ata***B***ase ***A***bstraction ***L***ayer with many features f
[GA 3.3 image]: https://github.com/doctrine/dbal/workflows/Continuous%20Integration/badge.svg?branch=3.3.x
[TypeCov 3.3]: https://shepherd.dev/github/doctrine/dbal
[TypeCov 3.3 image]: https://shepherd.dev/github/doctrine/dbal/coverage.svg

[Coverage 2.13 image]: https://codecov.io/gh/doctrine/dbal/branch/2.13.x/graph/badge.svg
[2.13]: https://github.com/doctrine/dbal/tree/2.13.x
[CodeCov 2.13]: https://codecov.io/gh/doctrine/dbal/branch/2.13.x
[AppVeyor 2.13]: https://ci.appveyor.com/project/doctrine/dbal/branch/2.13.x
[AppVeyor 2.13 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/2.13.x?svg=true
[GA 2.13]: https://github.com/doctrine/dbal/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A2.13.x
[GA 2.13 image]: https://github.com/doctrine/dbal/workflows/Continuous%20Integration/badge.svg?branch=2.13.x
766 changes: 0 additions & 766 deletions UPGRADE.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -41,7 +41,7 @@
"require-dev": {
"doctrine/coding-standard": "9.0.0",
"jetbrains/phpstorm-stubs": "2021.1",
"phpstan/phpstan": "1.4.6",
"phpstan/phpstan": "1.5.3",
"phpstan/phpstan-phpunit": "1.0.0",
"phpstan/phpstan-strict-rules": "1.1.0",
"phpunit/phpunit": "9.5.16",
Expand Down
4 changes: 0 additions & 4 deletions docs/en/reference/portability.rst
Expand Up @@ -36,8 +36,6 @@ can use to write a portable application.
Connection Wrapper
------------------

This functionality is only implemented with Doctrine DBAL 2.1 upwards.

To handle all the points 1-3 you have to use a special wrapper around the database
connection. The handling and differences to tackle are all taken from the great
`PEAR MDB2 library <http://pear.php.net/package/MDB2/redirected>`_.
Expand Down Expand Up @@ -79,8 +77,6 @@ at all the different methods that the platforms allow you to access.
Keyword Lists
-------------

This functionality is only implemented with Doctrine DBAL 2.1 upwards.

Doctrine ships with lists of keywords for every supported vendor. You
can access a keyword list through the schema manager of the vendor you
are currently using or just instantiating it from the ``Doctrine\DBAL\Platforms\Keywords``
Expand Down
39 changes: 0 additions & 39 deletions docs/en/reference/types.rst
Expand Up @@ -262,10 +262,6 @@ The immutable variant of the ``date`` type.
Values retrieved from the database are always converted to PHP's ``\DateTimeImmutable``
object or ``null`` if no data is present.

.. note::

Available since version ``2.6``.

datetime
^^^^^^^^

Expand Down Expand Up @@ -296,10 +292,6 @@ The immutable variant of the ``datetime`` type.
Values retrieved from the database are always converted to PHP's ``\DateTimeImmutable``
object or ``null`` if no data is present.

.. note::

Available since version ``2.6``.

datetimetz
^^^^^^^^^^

Expand All @@ -316,10 +308,6 @@ The immutable variant of the ``datetimetz`` type.
Values retrieved from the database are always converted to PHP's ``\DateTimeImmutable``
object or ``null`` if no data is present.

.. note::

Available since version ``2.6``.

time
^^^^

Expand All @@ -336,10 +324,6 @@ The immutable variant of the ``time`` type.
Values retrieved from the database are always converted to PHP's ``\DateTimeImmutable``
object or ``null`` if no data is present.

.. note::

Available since version ``2.6``.

dateinterval
^^^^^^^^^^^^

Expand Down Expand Up @@ -454,29 +438,6 @@ JSON objects are always converted to PHP associative arrays.
like MySQL sort the keys of its native JSON type using an internal order
which is also subject to change.

json_array
^^^^^^^^^^

.. warning::

This type is deprecated since 2.6, you should use ``json`` instead.

Maps and converts array data based on PHP's JSON encoding functions.
If you know that the data to be stored always is in a valid UTF-8
encoded JSON format string, you should consider using this type.
Values retrieved from the database are always converted to PHP's ``array`` type
using PHP's ``json_decode()`` function.

.. note::

Some vendors have a native JSON type and Doctrine will use it if possible
and otherwise silently fall back to the vendor's ``text`` type to ensure
the most efficient storage requirements.
If the vendor does not have a native JSON type, this type requires an SQL
column comment hint so that it can be reverse engineered from the database.
Doctrine cannot map back this type properly on vendors not supporting column
comments and will fall back to ``text`` type instead.

Object types
~~~~~~~~~~~~

Expand Down
9 changes: 1 addition & 8 deletions src/Driver/PDO/Result.php
Expand Up @@ -9,9 +9,6 @@
use PDOException;
use PDOStatement;

use function assert;
use function is_array;

final class Result implements ResultInterface
{
private PDOStatement $statement;
Expand Down Expand Up @@ -106,13 +103,9 @@ private function fetch(int $mode): mixed
private function fetchAll(int $mode): array
{
try {
$data = $this->statement->fetchAll($mode);
return $this->statement->fetchAll($mode);
} catch (PDOException $exception) {
throw Exception::new($exception);
}

assert(is_array($data));

return $data;
}
}
4 changes: 4 additions & 0 deletions src/Logging/Driver.php
Expand Up @@ -46,6 +46,10 @@ private function maskPassword(array $params): array
$params['password'] = '<redacted>';
}

if (isset($params['url'])) {
$params['url'] = '<redacted>';
}

return $params;
}
}
9 changes: 0 additions & 9 deletions src/Platforms/AbstractMySQLPlatform.php
Expand Up @@ -368,15 +368,6 @@ public function getAlterTableSQL(TableDiff $diff): array
$column = $columnDiff->column;
$columnArray = $column->toArray();

// Don't propagate default value changes for unsupported column types.
if (
$columnDiff->hasChanged('default') &&
count($columnDiff->changedProperties) === 1 &&
($columnArray['type'] instanceof TextType || $columnArray['type'] instanceof BlobType)
) {
continue;
}

$columnArray['comment'] = $column->getComment();
$queryParts[] = 'CHANGE ' . ($columnDiff->getOldColumnName()->getQuotedName($this)) . ' '
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
Expand Down
2 changes: 2 additions & 0 deletions src/Platforms/AbstractPlatform.php
Expand Up @@ -862,6 +862,8 @@ public function getDropUniqueConstraintSQL(string $name, string $tableName): str
* Returns the SQL statement(s) to create a table with the specified name, columns and constraints
* on this platform.
*
* @psalm-param int-mask-of<self::CREATE_*> $createFlags
*
* @return array<int, string> The sequence of SQL statements.
*
* @throws Exception
Expand Down
11 changes: 11 additions & 0 deletions src/Platforms/MariaDBPlatform.php
Expand Up @@ -19,6 +19,17 @@
*/
class MariaDBPlatform extends AbstractMySQLPlatform
{
/**
* {@inheritDoc}
*
* Hop over the {@see AbstractMySQLPlatform} implementation until 4.0.x
* where {@see MariaDBPlatform} no longer extends {@see MySQLPlatform}.
*/
public function getDefaultValueDeclarationSQL(array $column): string
{
return AbstractPlatform::getDefaultValueDeclarationSQL($column);
}

/**
* {@inheritdoc}
*
Expand Down
17 changes: 15 additions & 2 deletions tests/Functional/Schema/ComparatorTest.php
Expand Up @@ -4,9 +4,12 @@

namespace Doctrine\DBAL\Tests\Functional\Schema;

use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Types\Types;

class ComparatorTest extends FunctionalTestCase
{
Expand All @@ -22,6 +25,15 @@ protected function setUp(): void
*/
public function testDefaultValueComparison(string $type, mixed $value): void
{
$platform = $this->connection->getDatabasePlatform();
if (
$type === Types::TEXT && $platform instanceof AbstractMySQLPlatform
&& ! $platform instanceof MariaDBPlatform
) {
// See https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-13.html#mysqld-8-0-13-data-types
self::markTestSkipped('Oracle MySQL does not support default values on TEXT/BLOB columns until 8.0.13.');
}

$table = new Table('default_value');
$table->addColumn('test', $type, ['default' => $value]);

Expand All @@ -41,8 +53,9 @@ public function testDefaultValueComparison(string $type, mixed $value): void
public static function defaultValueProvider(): iterable
{
return [
['integer', 1],
['boolean', false],
[Types::INTEGER, 1],
[Types::BOOLEAN, false],
[Types::TEXT, 'Doctrine'],
];
}
}
2 changes: 2 additions & 0 deletions tests/Logging/MiddlewareTest.php
Expand Up @@ -44,6 +44,7 @@ public function testConnectAndDisconnect(): void
'params' => [
'username' => 'admin',
'password' => '<redacted>',
'url' => '<redacted>',
],
],
],
Expand All @@ -53,6 +54,7 @@ public function testConnectAndDisconnect(): void
$this->driver->connect([
'username' => 'admin',
'password' => 'Passw0rd!',
'url' => 'mysql://user:secret@localhost/mydb',
]);
}

Expand Down

0 comments on commit d2420a2

Please sign in to comment.