diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 07d12226501..98fcb3cfc0a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -91,9 +91,9 @@ jobs: ENABLE_SECOND_LEVEL_CACHE: 1 - name: "Upload coverage file" - uses: "actions/upload-artifact@v3" + uses: "actions/upload-artifact@v4" with: - name: "phpunit-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-coverage" + name: "phpunit-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-${{ matrix.proxy }}-coverage" path: "coverage*.xml" @@ -164,9 +164,9 @@ jobs: run: "vendor/bin/phpunit -c ci/github/phpunit/pdo_pgsql.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.php-version }}-${{ matrix.dbal-version }}-coverage" + name: "${{ github.job }}-${{ matrix.postgres-version }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-${{ matrix.extension }}-coverage" path: "coverage.xml" @@ -230,7 +230,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 }}-${{ matrix.dbal-version }}-coverage" path: "coverage.xml" @@ -311,7 +311,7 @@ jobs: ENABLE_SECOND_LEVEL_CACHE: 1 - name: "Upload coverage files" - uses: "actions/upload-artifact@v3" + uses: "actions/upload-artifact@v4" with: name: "${{ github.job }}-${{ matrix.mysql-version }}-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-coverage" path: "coverage*.xml" @@ -332,7 +332,7 @@ jobs: fetch-depth: 2 - name: "Download coverage files" - uses: "actions/download-artifact@v3" + uses: "actions/download-artifact@v4" with: path: "reports" diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index f0bbf5b9e2a..bd9ebea8d28 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -27,7 +27,7 @@ jobs: uses: "shivammathur/setup-php@v2" with: coverage: "none" - php-version: "8.2" + php-version: "8.3" - name: "Remove existing composer file" run: "rm composer.json" diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml index c4389142616..d46dc4c36bb 100644 --- a/.github/workflows/release-on-milestone-closed.yml +++ b/.github/workflows/release-on-milestone-closed.yml @@ -7,7 +7,7 @@ on: jobs: release: - uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@3.0.0" + uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@4.0.0" secrets: GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }} GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 32478b18cc1..5082f75051d 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -43,7 +43,7 @@ jobs: uses: shivammathur/setup-php@v2 with: coverage: none - php-version: "8.2" + php-version: "8.3" tools: cs2pr - name: Require specific DBAL version @@ -75,7 +75,7 @@ jobs: uses: shivammathur/setup-php@v2 with: coverage: none - php-version: "8.2" + php-version: "8.3" tools: cs2pr - name: Require specific DBAL version diff --git a/src/Tools/SchemaTool.php b/src/Tools/SchemaTool.php index 13ce5ed6993..42b52df8c71 100644 --- a/src/Tools/SchemaTool.php +++ b/src/Tools/SchemaTool.php @@ -337,7 +337,7 @@ public function getSchemaFromMetadata(array $classes): Schema if (isset($class->table['uniqueConstraints'])) { foreach ($class->table['uniqueConstraints'] as $indexName => $indexData) { - $uniqIndex = new Index($indexName, $this->getIndexColumns($class, $indexData), true, false, [], $indexData['options'] ?? []); + $uniqIndex = new Index('tmp__' . $indexName, $this->getIndexColumns($class, $indexData), true, false, [], $indexData['options'] ?? []); foreach ($table->getIndexes() as $tableIndexName => $tableIndex) { if ($tableIndex->isFulfilledBy($uniqIndex)) { diff --git a/tests/Tests/ORM/Tools/SchemaToolTest.php b/tests/Tests/ORM/Tools/SchemaToolTest.php index d917254721e..a1f3e77d70c 100644 --- a/tests/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Tests/ORM/Tools/SchemaToolTest.php @@ -370,6 +370,27 @@ public function testConfigurationSchemaIgnoredEntity(): void self::assertTrue($schema->hasTable('first_entity'), 'Table first_entity should exist.'); self::assertFalse($schema->hasTable('second_entity'), 'Table second_entity should not exist.'); } + + #[Group('GH-11314')] + public function testLoadUniqueConstraintWithoutName(): void + { + $em = $this->getTestEntityManager(); + $entity = $em->getClassMetadata(GH11314Entity::class); + + $schemaTool = new SchemaTool($em); + $schema = $schemaTool->getSchemaFromMetadata([$entity]); + + self::assertTrue($schema->hasTable('GH11314Entity')); + + $tableEntity = $schema->getTable('GH11314Entity'); + + self::assertTrue($tableEntity->hasIndex('uniq_2d81a3ed5bf54558875f7fd5')); + + $tableIndex = $tableEntity->getIndex('uniq_2d81a3ed5bf54558875f7fd5'); + + self::assertTrue($tableIndex->isUnique()); + self::assertSame(['field', 'anotherField'], $tableIndex->getColumns()); + } } #[Table(options: ['foo' => 'bar', 'baz' => ['key' => 'val']])] @@ -500,6 +521,21 @@ class IndexByFieldEntity public $fieldName; } +#[Entity] +#[UniqueConstraint(columns: ['field', 'anotherField'])] +class GH11314Entity +{ + #[Column] + #[Id] + private int $id; + + #[Column(name: 'field')] + private string $field; + + #[Column(name: 'anotherField')] + private string $anotherField; +} + class IncorrectIndexByFieldEntity { /** @var int */