Commit e144166d authored by S38151's avatar S38151

fixed unqualified table name of fk constraints when using schemas

parent c0b38924
......@@ -218,7 +218,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
$position = strrpos($name, '.');
if ($position !== false) {
$name = substr($name, $position);
$name = substr($name, $position + 1);
}
return strtolower($name);
......
......@@ -6,6 +6,7 @@ namespace Doctrine\Tests\DBAL\Schema;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use PHPUnit\Framework\TestCase;
class ForeignKeyConstraintTest extends TestCase
......@@ -58,4 +59,30 @@ class ForeignKeyConstraintTest extends TestCase
[['FOO'], true],
];
}
/**
* @param string|Table $foreignTableName
*
* @group DBAL-1062
* @dataProvider getUnqualifiedForeignTableNameData
*/
public function testGetUnqualifiedForeignTableName($foreignTableName, string $expectedUnqualifiedTableName) : void
{
$foreignKey = new ForeignKeyConstraint(['foo', 'bar'], $foreignTableName, ['fk_foo', 'fk_bar']);
self::assertSame($expectedUnqualifiedTableName, $foreignKey->getUnqualifiedForeignTableName());
}
/**
* @return mixed[][]
*/
public static function getUnqualifiedForeignTableNameData() : iterable
{
return [
['schema.foreign_table', 'foreign_table'],
['foreign_table', 'foreign_table'],
[new Table('schema.foreign_table'), 'foreign_table'],
[new Table('foreign_table'), 'foreign_table'],
];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment