Skip to content

Commit

Permalink
Merge pull request #4820 from morozov/3.2.x
Browse files Browse the repository at this point in the history
Merge 3.1.x into 3.2.x
  • Loading branch information
derrabus authored Sep 28, 2021
2 parents 09929a3 + 343814f commit bacdbce
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Platforms/SqlitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ public function getAlterTableSQL(TableDiff $diff)
private function replaceColumn($tableName, array $columns, $columnName, Column $column): array
{
$keys = array_keys($columns);
$index = array_search($columnName, $keys, true);
$index = array_search(strtolower($columnName), $keys, true);

if ($index === false) {
throw SchemaException::columnDoesNotExist($columnName, $tableName);
Expand Down
9 changes: 9 additions & 0 deletions src/Schema/SqliteSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,4 +577,13 @@ public function createComparator(): Comparator
{
return new SQLite\Comparator($this->getDatabasePlatform());
}

/**
* {@inheritDoc}
*/
public function getSchemaSearchPaths()
{
// SQLite does not support schemas or databases
return [];
}
}
22 changes: 19 additions & 3 deletions tests/Functional/Platform/RenameColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@

class RenameColumnTest extends FunctionalTestCase
{
public function testColumnPositionRetainedAfterRenaming(): void
/**
* @dataProvider columnNameProvider
*/
public function testColumnPositionRetainedAfterRenaming(string $columnName): void
{
if ($columnName === 'C1') {
self::markTestIncomplete('See https://github.com/doctrine/dbal/issues/4816');
}

$table = new Table('test_rename');
$table->addColumn('c1', 'string');
$table->addColumn($columnName, 'string');
$table->addColumn('c2', 'integer');

$sm = $this->connection->createSchemaManager();
$sm->dropAndCreateTable($table);

$table->dropColumn('c1')
$table->dropColumn($columnName)
->addColumn('c1_x', 'string');

$comparator = new Comparator();
Expand All @@ -31,4 +38,13 @@ public function testColumnPositionRetainedAfterRenaming(): void
$table = $sm->listTableDetails('test_rename');
self::assertSame(['c1_x', 'c2'], array_keys($table->getColumns()));
}

/**
* @return iterable<array{string}>
*/
public static function columnNameProvider(): iterable
{
yield ['c1'];
yield ['C1'];
}
}
17 changes: 17 additions & 0 deletions tests/Functional/Schema/SchemaTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Doctrine\DBAL\Tests\Functional\Schema;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Tests\FunctionalTestCase;

class SchemaTest extends FunctionalTestCase
{
public function testSchemaName(): void
{
$schema = new Schema([], [], $this->connection->createSchemaManager()->createSchemaConfig());
self::assertNotEmpty($schema->getName());
}
}

0 comments on commit bacdbce

Please sign in to comment.