From f94400667ccd16c64862cb18625763c5f7d5bccf 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] Create failing tests for index creation in other schema for SQLite --- tests/Functional/Platform/OtherSchemaTest.php | 27 +++++++++++++++++++ tests/Platforms/SqlitePlatformTest.php | 20 +++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/Functional/Platform/OtherSchemaTest.php diff --git a/tests/Functional/Platform/OtherSchemaTest.php b/tests/Functional/Platform/OtherSchemaTest.php new file mode 100644 index 00000000000..e18cd7e8083 --- /dev/null +++ b/tests/Functional/Platform/OtherSchemaTest.php @@ -0,0 +1,27 @@ +connection->getDatabasePlatform() instanceof SqlitePlatform)) { + self::markTestSkipped('This test requires SQLite'); + } + + $this->connection->executeStatement("ATTACH DATABASE '/tmp/test_other_schema.sqlite' AS other"); + $this->connection->getDatabasePlatform()->disableSchemaEmulation(); + + $table = new Table('other.test_other_schema'); + $table->addColumn('id', Types::INTEGER); + $table->addIndex(['id']); + + $this->dropAndCreateTable($table); + } +} diff --git a/tests/Platforms/SqlitePlatformTest.php b/tests/Platforms/SqlitePlatformTest.php index 94de2f0db73..981af4d4db0 100644 --- a/tests/Platforms/SqlitePlatformTest.php +++ b/tests/Platforms/SqlitePlatformTest.php @@ -17,7 +17,10 @@ class SqlitePlatformTest extends AbstractPlatformTestCase { public function createPlatform(): AbstractPlatform { - return new SqlitePlatform(); + $platform = new SqlitePlatform(); + $platform->disableSchemaEmulation(); + + return $platform; } public function getGenerateTableSql(): string @@ -768,4 +771,19 @@ public function testGetCreateTableSQLWithColumnCollation(): void $this->platform->getCreateTableSQL($table), ); } + + public function testCreateTableInOtherSchema(): void + { + $table = new Table('other_schema.foo'); + $table->addColumn('id', Types::INTEGER); + $table->addIndex(['id']); + + self::assertSame( + [ + 'CREATE TABLE other_schema.foo (id INTEGER NOT NULL)', + 'CREATE INDEX other_schema.IDX_8C73652176FF8CAA ON foo (id)', + ], + $this->platform->getCreateTableSQL($table), + ); + } }