|
12 | 12 | use Doctrine\DBAL\Types\BlobType;
|
13 | 13 | use Doctrine\DBAL\Types\Type;
|
14 | 14 | use Doctrine\DBAL\Types\Types;
|
| 15 | +use ReflectionMethod; |
15 | 16 |
|
16 | 17 | use function array_keys;
|
| 18 | +use function array_map; |
17 | 19 | use function array_shift;
|
18 | 20 | use function assert;
|
19 | 21 | use function dirname;
|
@@ -397,4 +399,55 @@ public function testShorthandInForeignKeyReferenceWithMultipleColumns(): void
|
397 | 399 | $createTableTrackSql,
|
398 | 400 | );
|
399 | 401 | }
|
| 402 | + |
| 403 | + public function testListTableNoSchemaEmulation(): void |
| 404 | + { |
| 405 | + $databasePlatform = $this->connection->getDatabasePlatform(); |
| 406 | + assert($databasePlatform instanceof SqlitePlatform); |
| 407 | + $databasePlatform->disableSchemaEmulation(); |
| 408 | + |
| 409 | + $this->dropTableIfExists('`list_table_no_schema_emulation.test`'); |
| 410 | + |
| 411 | + $this->connection->executeStatement(<<<'DDL' |
| 412 | + CREATE TABLE `list_table_no_schema_emulation.test` ( |
| 413 | + id INTEGER, |
| 414 | + parent_id INTEGER, |
| 415 | + PRIMARY KEY (id), |
| 416 | + FOREIGN KEY (parent_id) REFERENCES `list_table_no_schema_emulation.test` (id) |
| 417 | + ); |
| 418 | + DDL); |
| 419 | + |
| 420 | + $this->connection->executeStatement(<<<'DDL' |
| 421 | + CREATE INDEX i ON `list_table_no_schema_emulation.test` (parent_id); |
| 422 | + DDL); |
| 423 | + |
| 424 | + $schemaManager = $this->schemaManager; |
| 425 | + $refl = new ReflectionMethod($schemaManager, 'selectTableColumns'); |
| 426 | + $refl->setAccessible(true); |
| 427 | + $res = $refl->invoke($schemaManager, 'main', 'list_table_no_schema_emulation.test') |
| 428 | + ->fetchAllAssociative(); |
| 429 | + |
| 430 | + self::assertSame([ |
| 431 | + ['list_table_no_schema_emulation.test', 'id'], |
| 432 | + ['list_table_no_schema_emulation.test', 'parent_id'], |
| 433 | + ], array_map(static fn (array $row) => [$row['table_name'], $row['name']], $res)); |
| 434 | + |
| 435 | + $refl = new ReflectionMethod($schemaManager, 'selectIndexColumns'); |
| 436 | + $refl->setAccessible(true); |
| 437 | + $res = $refl->invoke($schemaManager, 'main', 'list_table_no_schema_emulation.test') |
| 438 | + ->fetchAllAssociative(); |
| 439 | + |
| 440 | + self::assertSame([ |
| 441 | + ['list_table_no_schema_emulation.test', 'i'], |
| 442 | + ], array_map(static fn (array $row) => [$row['table_name'], $row['name']], $res)); |
| 443 | + |
| 444 | + $refl = new ReflectionMethod($schemaManager, 'selectForeignKeyColumns'); |
| 445 | + $refl->setAccessible(true); |
| 446 | + $res = $refl->invoke($schemaManager, 'main', 'list_table_no_schema_emulation.test') |
| 447 | + ->fetchAllAssociative(); |
| 448 | + |
| 449 | + self::assertSame([ |
| 450 | + ['list_table_no_schema_emulation.test', 'parent_id', 'id'], |
| 451 | + ], array_map(static fn (array $row) => [$row['table_name'], $row['from'], $row['to']], $res)); |
| 452 | + } |
400 | 453 | }
|
0 commit comments