Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport DBAL-related fixes #10105

Merged
merged 3 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/Doctrine/ORM/Tools/SchemaTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ static function (ClassMetadata $class) use ($idMapping): bool {
$uniqIndex = new Index($indexName, $this->getIndexColumns($class, $indexData), true, false, [], $indexData['options'] ?? []);

foreach ($table->getIndexes() as $tableIndexName => $tableIndex) {
if ($tableIndex->isFullfilledBy($uniqIndex)) {
$method = method_exists($tableIndex, 'isFulfilledBy') ? 'isFulfilledBy' : 'isFullfilledBy';
if ($tableIndex->$method($uniqIndex)) {
$table->dropIndex($tableIndexName);
break;
}
Expand Down Expand Up @@ -856,8 +857,12 @@ public function dropDatabase()
*/
public function getDropDatabaseSQL()
{
$method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ?
'introspectSchema' :
'createSchema';

return $this->schemaManager
->createSchema()
->$method()
->toDropSql($this->platform);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/Models/StockExchange/Stock.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Stock

/**
* @var float
* @Column(type="decimal")
* @Column(type="decimal", precision=10)
*/
private $price;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

namespace Doctrine\Tests\ORM\Functional\SchemaTool;

use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Tests\OrmFunctionalTestCase;

use function method_exists;

/**
* Functional tests for the Class Table Inheritance mapping strategy.
*/
Expand All @@ -21,7 +24,10 @@ protected function setUp(): void
/** @group DDC-966 */
public function testGeneratedSchema(): Schema
{
$schema = $this->createSchemaManager()->createSchema();
$method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ?
'introspectSchema' :
'createSchema';
$schema = $this->createSchemaManager()->$method();

self::assertTrue($schema->hasTable('company_contracts'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\Tests\ORM\Functional\SchemaTool;

use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\Tests\Models;
use Doctrine\Tests\OrmFunctionalTestCase;
Expand Down Expand Up @@ -67,7 +68,10 @@ public function assertCreatedSchemaNeedsNoUpdates(string ...$classes): void

$sm = $this->createSchemaManager();

$fromSchema = $sm->createSchema();
$method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ?
'introspectSchema' :
'createSchema';
$fromSchema = $sm->$method();
$toSchema = $this->getSchemaForModels(...$classes);

if (method_exists($sm, 'createComparator')) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class GH7941Product

/**
* @var string
* @Column(type="decimal")
* @Column(type="decimal", precision=10)
*/
public $price;

Expand Down
5 changes: 4 additions & 1 deletion tests/Doctrine/Tests/TestUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ private static function initializeDatabase(): void
$platform = $privConn->getDatabasePlatform();

if ($platform instanceof SqlitePlatform) {
$schema = self::createSchemaManager($testConn)->createSchema();
$method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ?
'introspectSchema' :
'createSchema';
$schema = self::createSchemaManager($testConn)->$method();
$stmts = $schema->toDropSql($testConn->getDatabasePlatform());

foreach ($stmts as $stmt) {
Expand Down