Skip to content

Commit

Permalink
Merge branch '4.0.x' into 4.1.x
Browse files Browse the repository at this point in the history
* 4.0.x:
  Bump CI workflows (#6323)
  Make all mapped database types case insensitive (#6321)
  Add gssencmode option to connection string for PgSQL & PDO PgSQL driver (#6320)
  Remove Type::canRequireSQLConversion from docs (#6318)
  • Loading branch information
derrabus committed Mar 3, 2024
2 parents 1d7b3e4 + 9e588fe commit 2edd1c7
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ on:
jobs:
coding-standards:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@3.1.0"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@4.0.0"
24 changes: 12 additions & 12 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ jobs:
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v3"
uses: "actions/upload-artifact@v4"
with:
name: "phpunit-${{ matrix.extension }}-${{ matrix.deps }}-${{ matrix.php-version }}.coverage"
name: "phpunit-${{ matrix.extension }}-${{ matrix.dependencies }}-${{ matrix.php-version }}.coverage"
path: "coverage.xml"

phpunit-oci8:
Expand Down Expand Up @@ -144,9 +144,9 @@ jobs:
run: "vendor/bin/phpunit -c ci/github/phpunit/oci8${{ matrix.oracle-version < 23 && '-21' || '' }}.xml --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v3"
uses: "actions/upload-artifact@v4"
with:
name: "${{ github.job }}-${{ matrix.php-version }}.coverage"
name: "${{ github.job }}-${{ matrix.php-version }}-${{ matrix.oracle-version }}.coverage"
path: "coverage.xml"

phpunit-pdo-oci:
Expand Down Expand Up @@ -201,9 +201,9 @@ jobs:
run: "vendor/bin/phpunit -c ci/github/phpunit/pdo_oci${{ matrix.oracle-version < 23 && '-21' || '' }}.xml --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v3"
uses: "actions/upload-artifact@v4"
with:
name: "${{ github.job }}-${{ matrix.php-version }}.coverage"
name: "${{ github.job }}-${{ matrix.php-version }}-${{ matrix.oracle-version }}.coverage"
path: "coverage.xml"

phpunit-postgres:
Expand Down Expand Up @@ -265,7 +265,7 @@ jobs:
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v3"
uses: "actions/upload-artifact@v4"
with:
name: "${{ github.job }}-${{ matrix.postgres-version }}-${{ matrix.extension }}-${{ matrix.php-version }}.coverage"
path: "coverage.xml"
Expand Down Expand Up @@ -334,7 +334,7 @@ jobs:
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v3"
uses: "actions/upload-artifact@v4"
with:
name: "${{ github.job }}-${{ matrix.mariadb-version }}-${{ matrix.extension }}-${{ matrix.php-version }}.coverage"
path: "coverage.xml"
Expand Down Expand Up @@ -409,7 +409,7 @@ jobs:
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}${{ matrix.config-file-suffix }}.xml --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v3"
uses: "actions/upload-artifact@v4"
with:
name: "${{ github.job }}-${{ matrix.mysql-version }}-${{ matrix.extension }}-${{ matrix.config-file-suffix }}-${{ matrix.php-version }}.coverage"
path: "coverage.xml"
Expand Down Expand Up @@ -476,7 +476,7 @@ jobs:
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v3"
uses: "actions/upload-artifact@v4"
with:
name: "${{ github.job }}-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.collation }}.coverage"
path: "coverage.xml"
Expand Down Expand Up @@ -547,7 +547,7 @@ jobs:
run: "vendor/bin/phpunit -c ci/github/phpunit/ibm_db2.xml --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v3"
uses: "actions/upload-artifact@v4"
with:
name: "${{ github.job }}-${{ matrix.php-version }}.coverage"
path: "coverage.xml"
Expand Down Expand Up @@ -601,7 +601,7 @@ jobs:
fetch-depth: 2

- name: "Download coverage files"
uses: "actions/download-artifact@v3"
uses: "actions/download-artifact@v4"
with:
path: "reports"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v6
- uses: actions/stale@v9
with:
stale-pr-message: >
There hasn't been any activity on this pull request in the past 90 days, so
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.2"
- "8.3"

steps:
- name: "Checkout code"
Expand All @@ -60,7 +60,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.2"
- "8.3"

steps:
- name: Checkout code
Expand Down
2 changes: 2 additions & 0 deletions docs/en/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ pdo_pgsql / pgsql
- ``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`
- ``gssencmode`` (string): Optional GSS-encrypted channel/GSSEncMode configuration.
See `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
17 changes: 3 additions & 14 deletions docs/en/reference/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -848,19 +848,8 @@ Now we implement our ``Doctrine\DBAL\Types\Type`` instance:

The job of Doctrine-DBAL is to transform your type into an SQL
declaration. You can modify the SQL declaration Doctrine will produce.
At first, to enable this feature, you must override the
``canRequireSQLConversion`` method:

::

<?php
public function canRequireSQLConversion()
{
return true;
}

Then you override the ``convertToPhpValueSQL`` and
``convertToDatabaseValueSQL`` methods :
At first, you override the ``convertToPhpValueSQL`` and
``convertToDatabaseValueSQL`` methods:

::

Expand All @@ -875,7 +864,7 @@ Then you override the ``convertToPhpValueSQL`` and
return 'MyFunction('.$sqlExpr.')';
}

Now we have to register this type with the Doctrine Type system and
Then you have to register this type with the Doctrine Type system and
hook it into the database platform:

::
Expand Down
4 changes: 4 additions & 0 deletions src/Driver/PDO/PgSQL/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ private function constructPdoDsn(array $params): string
$dsn .= 'application_name=' . $params['application_name'] . ';';
}

if (isset($params['gssencmode'])) {
$dsn .= 'gssencmode=' . $params['gssencmode'] . ';';
}

return $dsn;
}
}
1 change: 1 addition & 0 deletions src/Driver/PgSQL/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private function constructConnectionString(
'user' => $params['user'] ?? null,
'password' => $params['password'] ?? null,
'sslmode' => $params['sslmode'] ?? null,
'gssencmode' => $params['gssencmode'] ?? null,
],
static fn (int|string|null $value) => $value !== '' && $value !== null,
);
Expand Down
1 change: 1 addition & 0 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ private function initializeAllDoctrineTypeMappings(): void

foreach (Type::getTypesMap() as $typeName => $className) {
foreach (Type::getType($typeName)->getMappedDatabaseTypes($this) as $dbType) {
$dbType = strtolower($dbType);
$this->doctrineTypeMapping[$dbType] = $typeName;
}
}
Expand Down
34 changes: 34 additions & 0 deletions tests/Platforms/AbstractPlatformTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,40 @@ public function testRegisterDoctrineMappingType(): void
self::assertEquals(Types::INTEGER, $this->platform->getDoctrineTypeMapping('foo'));
}

public function testCaseInsensitiveDoctrineTypeMappingFromType(): void
{
$type = new class () extends Type {
/**
* {@inheritDoc}
*/
public function getMappedDatabaseTypes(AbstractPlatform $platform): array
{
return ['TESTTYPE'];
}

public function getName(): string
{
return 'testtype';
}

/**
* {@inheritDoc}
*/
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
return $platform->getDecimalTypeDeclarationSQL($column);
}
};

if (Type::hasType($type->getName())) {
Type::overrideType($type->getName(), $type::class);
} else {
Type::addType($type->getName(), $type::class);
}

self::assertSame($type->getName(), $this->platform->getDoctrineTypeMapping('TeStTyPe'));
}

public function testRegisterUnknownDoctrineMappingType(): void
{
$this->expectException(Exception::class);
Expand Down

0 comments on commit 2edd1c7

Please sign in to comment.