From dc42058da5b52416eb634ea2bcb10b530b55567e Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 23 Nov 2023 21:06:15 +0100 Subject: [PATCH 1/2] CI: Drop MariaDB 10.10, add MariaDB 11.2 (#6229) | Q | A |------------- | ----------- | Type | improvement | Fixed issues | N/A #### Summary MariaDB 11.2 has been released, MariaDB 10.10 is EOL. --- .github/workflows/continuous-integration.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 4eca2d350f..096f8c174e 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -300,10 +300,10 @@ jobs: - "10.4" # LTS (Jun 2024) - "10.5" # LTS (Jun 2025) - "10.6" # LTS (Jul 2026) - - "10.10" # STS (Nov 2023) - "10.11" # LTS (Feb 2028) - "11.0" # STS (Jun 2024) - "11.1" # STS (Aug 2024) + - "11.2" # STS (Nov 2024) extension: - "mysqli" - "pdo_mysql" @@ -315,16 +315,16 @@ jobs: mariadb-version: "10.6" extension: "pdo_mysql" - php-version: "8.2" - mariadb-version: "11.1" + mariadb-version: "11.2" extension: "mysqli" - php-version: "8.2" - mariadb-version: "11.1" + mariadb-version: "11.2" extension: "pdo_mysql" - php-version: "8.3" - mariadb-version: "11.1" + mariadb-version: "11.2" extension: "mysqli" - php-version: "8.3" - mariadb-version: "11.1" + mariadb-version: "11.2" extension: "pdo_mysql" services: From bc7afc15c6912ca8a6d6894d6e6bc1b2b013b5b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 21 Nov 2023 13:47:50 +0100 Subject: [PATCH 2/2] Move schema part to the index In SQLite, creating an index in another schema is done by prepending the index name with the schema, while the table name must be unprefixed. --- psalm.xml.dist | 1 + src/Platforms/SqlitePlatform.php | 45 +++++++++++++++++++ tests/Functional/Platform/OtherSchemaTest.php | 37 +++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 tests/Functional/Platform/OtherSchemaTest.php diff --git a/psalm.xml.dist b/psalm.xml.dist index 567ecc381a..8b16d961b5 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -326,6 +326,7 @@ + diff --git a/src/Platforms/SqlitePlatform.php b/src/Platforms/SqlitePlatform.php index 5acefc5c82..f11e537e60 100644 --- a/src/Platforms/SqlitePlatform.php +++ b/src/Platforms/SqlitePlatform.php @@ -18,6 +18,7 @@ use Doctrine\DBAL\Types; use Doctrine\DBAL\Types\IntegerType; use Doctrine\Deprecations\Deprecation; +use InvalidArgumentException; use function array_combine; use function array_keys; @@ -26,12 +27,14 @@ use function array_unique; use function array_values; use function count; +use function explode; use function implode; use function is_numeric; use function sprintf; use function sqrt; use function str_replace; use function strlen; +use function strpos; use function strtolower; use function trim; @@ -918,6 +921,48 @@ public function getCreateTablesSQL(array $tables): array return $sql; } + /** + * {@inheritDoc} + */ + public function getCreateIndexSQL(Index $index, $table) + { + if ($table instanceof Table) { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/4798', + 'Passing $table as a Table object to %s is deprecated. Pass it as a quoted name instead.', + __METHOD__, + ); + + $table = $table->getQuotedName($this); + } + + $name = $index->getQuotedName($this); + $columns = $index->getColumns(); + + if (strpos($table, '.') !== false) { + [$schema, $table] = explode('.', $table); + $name = $schema . '.' . $name; + } + + if (count($columns) === 0) { + throw new InvalidArgumentException(sprintf( + 'Incomplete or invalid index definition %s on table %s', + $name, + $table, + )); + } + + if ($index->isPrimary()) { + return $this->getCreatePrimaryKeySQL($index, $table); + } + + $query = 'CREATE ' . $this->getCreateIndexSQLFlags($index) . 'INDEX ' . $name . ' ON ' . $table; + $query .= ' (' . $this->getIndexFieldDeclarationListSQL($index) . ')' . $this->getPartialIndexSQL($index); + + return $query; + } + /** * {@inheritDoc} */ diff --git a/tests/Functional/Platform/OtherSchemaTest.php b/tests/Functional/Platform/OtherSchemaTest.php new file mode 100644 index 0000000000..93fad96872 --- /dev/null +++ b/tests/Functional/Platform/OtherSchemaTest.php @@ -0,0 +1,37 @@ +connection->getDatabasePlatform(); + if (! ($databasePlatform instanceof SqlitePlatform)) { + self::markTestSkipped('This test requires SQLite'); + } + + $this->connection->executeStatement("ATTACH DATABASE '/tmp/test_other_schema.sqlite' AS other"); + $databasePlatform->disableSchemaEmulation(); + + $table = new Table('other.test_other_schema'); + $table->addColumn('id', Types::INTEGER); + $table->addIndex(['id']); + + $this->dropAndCreateTable($table); + $this->connection->insert('other.test_other_schema', ['id' => 1]); + + self::assertEquals(1, $this->connection->fetchOne('SELECT COUNT(*) FROM other.test_other_schema')); + $connection = DriverManager::getConnection( + ['url' => 'sqlite:////tmp/test_other_schema.sqlite'], + ); + $onlineTable = $connection->createSchemaManager()->introspectTable('test_other_schema'); + self::assertCount(1, $onlineTable->getIndexes()); + } +}