Skip to content

Commit

Permalink
Merge pull request #6581 from doctrine/4.2.x
Browse files Browse the repository at this point in the history
Merge 4.2.x up into 4.3.x
  • Loading branch information
greg0ire authored Nov 2, 2024
2 parents 4b084f6 + 604277e commit e77da49
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 136 deletions.
33 changes: 0 additions & 33 deletions .github/ISSUE_TEMPLATE/Bug.md

This file was deleted.

17 changes: 0 additions & 17 deletions .github/ISSUE_TEMPLATE/Feature_Request.md

This file was deleted.

20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/Support_Question.md

This file was deleted.

16 changes: 8 additions & 8 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,23 @@ jobs:
- "8.1"
postgres-version:
- "10"
- "15"
- "16"
- "17"
extension:
- "pgsql"
- "pdo_pgsql"
include:
- php-version: "8.2"
postgres-version: "16"
postgres-version: "17"
extension: "pgsql"
- php-version: "8.3"
postgres-version: "16"
postgres-version: "17"
extension: "pgsql"
- php-version: "8.4"
postgres-version: "16"
postgres-version: "17"
extension: "pgsql"
- php-version: "8.4"
postgres-version: "16"
postgres-version: "17"
extension: "pdo_pgsql"

services:
Expand Down Expand Up @@ -372,7 +372,7 @@ jobs:
mysql-version:
- "5.7"
- "8.0"
- "9.0"
- "9.1"
extension:
- "mysqli"
- "pdo_mysql"
Expand Down Expand Up @@ -401,10 +401,10 @@ jobs:
custom-entrypoint: >-
--entrypoint sh mysql:8.4 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON"
- php-version: "8.4"
mysql-version: "9.0"
mysql-version: "9.1"
extension: "mysqli"
- php-version: "8.4"
mysql-version: "9.0"
mysql-version: "9.1"
extension: "pdo_mysql"

services:
Expand Down
20 changes: 10 additions & 10 deletions docs/en/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ mysqli
- ``ssl_ca`` (string): The path name to the certificate authority file to use for SSL encryption.
- ``ssl_capath`` (string): The pathname to a directory that contains trusted SSL CA certificates in PEM format.
- ``ssl_cipher`` (string): A list of allowable ciphers to use for SSL encryption.
- ``driverOptions`` Any supported flags for mysqli found on `http://www.php.net/manual/en/mysqli.real-connect.php`
- ``driverOptions`` Any supported flags for mysqli found on `www.php.net/manual/en/mysqli.real-connect.php <https://www.php.net/manual/en/mysqli.real-connect.php>`_

pdo_pgsql / pgsql
^^^^^^^^^^^^^^^^^
Expand All @@ -266,22 +266,22 @@ pdo_pgsql / pgsql
- ``sslmode`` (string): Determines whether or with what priority
a SSL TCP/IP connection will be negotiated with the server.
See the list of available modes:
`https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLMODE`
`www.postgresql.org/docs/9.4/libpq-connect.html#LIBPQ-CONNECT-SSLMODE <https://www.postgresql.org/docs/9.4/libpq-connect.html#LIBPQ-CONNECT-SSLMODE>`_
- ``sslrootcert`` (string): specifies the name of a file containing
SSL certificate authority (CA) certificate(s). If the file exists,
the server's certificate will be verified to be signed by one of these
authorities.
See https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT
See `www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT <https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT>`_
- ``sslcert`` (string): specifies the filename of the client SSL certificate.
See `https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLCERT`
See `www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLCERT <https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLCERT>`_
- ``sslkey`` (string): specifies the location for the secret key used for the
client certificate.
See `https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLKEY`
See `www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLKEY <https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLKEY>`_
- ``sslcrl`` (string): specifies the filename of the SSL certificate
revocation list (CRL).
See `https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLCRL`
See `www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLCRL <https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLCRL>`_
- ``gssencmode`` (string): Optional GSS-encrypted channel/GSSEncMode configuration.
See `https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-GSSENCMODE`
See `www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-GSSENCMODE <https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-GSSENCMODE>`_
- ``application_name`` (string): Name of the application that is
connecting to database. Optional. It will be displayed at ``pg_stat_activity``.

Expand Down Expand Up @@ -316,7 +316,7 @@ pdo_oci / oci8
add the INSTANCE_NAME parameter in the connection. It is generally used
to connect to an Oracle RAC server to select the name of a particular instance.
- ``connectstring`` (string): Complete Easy Connect connection descriptor,
see https://docs.oracle.com/database/121/NETAG/naming.htm. When using this option,
see `docs.oracle.com/en/database/oracle/oracle-database/23/netag/configuring-naming-methods.html <https://docs.oracle.com/en/database/oracle/oracle-database/23/netag/configuring-naming-methods.html>`_. When using this option,
you will still need to provide the ``user`` and ``password`` parameters, but the other
parameters will no longer be used. Note that when using this parameter, the ``getHost``
and ``getPort`` methods from ``Doctrine\DBAL\Connection`` will no longer function as expected.
Expand All @@ -335,7 +335,7 @@ pdo_sqlsrv / sqlsrv
- ``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.
- ``driverOptions`` (array): Any supported options found on `https://learn.microsoft.com/en-us/sql/connect/php/connection-options`
- ``driverOptions`` (array): Any supported options found on `learn.microsoft.com/en-us/sql/connect/php/connection-options <https://learn.microsoft.com/en-us/sql/connect/php/connection-options>`_

ibm_db2
^^^^^^^
Expand All @@ -347,7 +347,7 @@ ibm_db2
- ``host`` (string): Hostname of the database to connect to.
- ``port`` (integer): Port of the database to connect to.
- ``persistent`` (boolean): Whether to establish a persistent connection.
- ``driverOptions`` (array): Any supported options found on `https://www.php.net/manual/en/function.db2-connect.php#refsect1-function.db2-connect-parameters`
- ``driverOptions`` (array): Any supported options found on `www.php.net/manual/en/function.db2-connect.php#refsect1-function.db2-connect-parameters <https://www.php.net/manual/en/function.db2-connect.php#refsect1-function.db2-connect-parameters>`_

Automatic platform version detection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
10 changes: 10 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@
<file name="tests/Types/DateIntervalTest.php"/>
</errorLevel>
</InaccessibleProperty>
<InvalidCast>
<errorLevel type="suppress">
<!-- See https://github.com/vimeo/psalm/issues/10995 -->
<file name="src/Types/BigIntType.php"/>
</errorLevel>
</InvalidCast>
<InvalidArgument>
<errorLevel type="suppress">
<!-- We're testing with invalid input here. -->
Expand Down Expand Up @@ -192,6 +198,8 @@
</MoreSpecificReturnType>
<NoValue>
<errorLevel type="suppress">
<!-- See https://github.com/vimeo/psalm/issues/10995 -->
<file name="src/Types/BigIntType.php"/>
<!--
This error looks bogus.
-->
Expand Down Expand Up @@ -298,6 +306,8 @@
<!-- Ignore isset() checks in destructors. -->
<file name="src/Driver/PgSQL/Connection.php"/>
<file name="src/Driver/PgSQL/Statement.php"/>
<!-- See https://github.com/vimeo/psalm/issues/10995 -->
<file name="src/Types/BigIntType.php"/>
</errorLevel>
</TypeDoesNotContainType>
<UndefinedClass>
Expand Down
5 changes: 1 addition & 4 deletions src/Schema/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,7 @@ final public function getRenamedColumns(): array
return $this->renamedColumns;
}

/**
* @throws LogicException
* @throws SchemaException
*/
/** @throws LogicException */
final public function renameColumn(string $oldName, string $newName): Column
{
$oldName = $this->normalizeIdentifier($oldName);
Expand Down
11 changes: 7 additions & 4 deletions src/Types/BigIntType.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): int
return $value;
}

if ($value > PHP_INT_MIN && $value < PHP_INT_MAX) {
return (int) $value;
}

assert(
is_string($value),
'DBAL assumes values outside of the integer range to be returned as string by the database driver.',
);

if (
($value > PHP_INT_MIN && $value < PHP_INT_MAX)
|| $value === (string) (int) $value
) {
return (int) $value;
}

return $value;
}
}
31 changes: 31 additions & 0 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use PHPUnit\Framework\TestCase;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
use RuntimeException;

/** @psalm-import-type Params from DriverManager */
#[RequiresPhpExtension('pdo_mysql')]
Expand Down Expand Up @@ -172,6 +173,36 @@ public function testCommitStartsTransactionInNoAutoCommitMode(): void
self::assertTrue($conn->isTransactionActive());
}

public function testBeginTransactionFailureAfterCommitInNoAutoCommitMode(): void
{
$driverConnectionMock = $this->createMock(DriverConnection::class);
$driverConnectionMock->expects(self::exactly(2))
->method('beginTransaction')
->willReturnOnConsecutiveCalls(
true,
self::throwException(new RuntimeException()),
);

$driver = self::createStub(Driver::class);
$driver
->method('connect')
->willReturn(
$driverConnectionMock,
);
$conn = new Connection([], $driver);

$conn->setAutoCommit(false);

/** Invoke protected {@see Connection::connect()} */
$conn->getServerVersion();
try {
$conn->commit();
} catch (RuntimeException) {
}

self::assertTrue($conn->isTransactionActive());
}

/** @return bool[][] */
public static function resultProvider(): array
{
Expand Down
44 changes: 4 additions & 40 deletions tests/Functional/Types/BigIntTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use Doctrine\DBAL\Types\Types;
use Generator;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Constraint\IsIdentical;
use PHPUnit\Framework\Constraint\LogicalOr;

use const PHP_INT_MAX;
use const PHP_INT_MIN;
Expand Down Expand Up @@ -49,44 +47,10 @@ public static function provideBigIntLiterals(): Generator
yield 'null' => ['null', null];
yield 'positive number' => ['42', 42];
yield 'negative number' => ['-42', -42];

if (PHP_INT_SIZE < 8) {
// The following tests only work on 64bit systems.
return;
}

yield 'large positive number' => ['9223372036854775806', PHP_INT_MAX - 1];
yield 'large negative number' => ['-9223372036854775807', PHP_INT_MIN + 1];
}

#[DataProvider('provideBigIntEdgeLiterals')]
public function testSelectBigIntEdge(int $value): void
{
$table = new Table('bigint_type_test');
$table->addColumn('id', Types::SMALLINT, ['notnull' => true]);
$table->addColumn('my_integer', Types::BIGINT, ['notnull' => false]);
$table->setPrimaryKey(['id']);
$this->dropAndCreateTable($table);

$this->connection->executeStatement(<<<SQL
INSERT INTO bigint_type_test (id, my_integer)
VALUES (42, $value)
SQL);

self::assertThat(
$this->connection->convertToPHPValue(
$this->connection->fetchOne('SELECT my_integer from bigint_type_test WHERE id = 42'),
Types::BIGINT,
),
LogicalOr::fromConstraints(new IsIdentical($value), new IsIdentical((string) $value)),
);
}

/** @return Generator<string, array{int}> */
public static function provideBigIntEdgeLiterals(): Generator
{
yield 'max int' => [PHP_INT_MAX];
yield 'min int' => [PHP_INT_MIN];
yield 'large positive number' => [PHP_INT_SIZE === 4 ? '2147483646' : '9223372036854775806', PHP_INT_MAX - 1];
yield 'large negative number' => [PHP_INT_SIZE === 4 ? '-2147483647' : '-9223372036854775807', PHP_INT_MIN + 1];
yield 'largest positive number' => [PHP_INT_SIZE === 4 ? '2147483647' : '9223372036854775807', PHP_INT_MAX];
yield 'largest negative number' => [PHP_INT_SIZE === 4 ? '-2147483648' : '-9223372036854775808', PHP_INT_MIN];
}

public function testUnsignedBigIntOnMySQL(): void
Expand Down

0 comments on commit e77da49

Please sign in to comment.