Skip to content

Commit e48897d

Browse files
committed
Fix for Issue #1487
1 parent a76ce4d commit e48897d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/Generator/DiffGenerator.php

+4
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ private function createToSchema(): Schema
146146
*/
147147
private function resolveTableName(string $name): string
148148
{
149+
if ($this->platform->supportsSchemas()) {
150+
return $name;
151+
}
152+
149153
$pos = strpos($name, '.');
150154

151155
return $pos === false ? $name : substr($name, $pos + 1);

tests/Generator/DiffGeneratorTest.php

+20-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,12 @@ public function testGenerateFromEmptySchema(): void
184184
self::assertSame('path2', $this->migrationDiffGenerator->generate('2345', null, false, 120, true, true));
185185
}
186186

187-
public function testGenerateAppliesFilterOnMappedSchema(): void
187+
/**
188+
* @param array<int, string> $expectedTables
189+
*
190+
* @dataProvider getGenerateAppliesFilterOnMappedSchemaData
191+
*/
192+
public function testGenerateAppliesFilterOnMappedSchema(bool $platformSupportsSchemas, array $expectedTables): void
188193
{
189194
// a standard Regex SchemaAssetsFilter already registered on the DBAL
190195
$dbalSchemaAssetsFilter = static function ($assetName): bool {
@@ -197,6 +202,10 @@ public function testGenerateAppliesFilterOnMappedSchema(): void
197202
$toTable2 = new Table('some_schema.table2');
198203
$toSchema = new Schema([$toTable1, $toTable2]);
199204

205+
$this->platform->expects(self::atLeast(1))
206+
->method('supportsSchemas')
207+
->willReturn($platformSupportsSchemas);
208+
200209
$this->schemaManager->expects(self::once())
201210
->method('introspectSchema')
202211
->willReturn($fromSchema);
@@ -224,7 +233,16 @@ public function testGenerateAppliesFilterOnMappedSchema(): void
224233

225234
$filteredTableNames = array_map(static fn (Table $table) => $table->getName(), $toSchema->getTables());
226235

227-
self::assertSame(['some_schema.table1', 'some_schema.table2'], array_values($filteredTableNames));
236+
self::assertSame($expectedTables, array_values($filteredTableNames));
237+
}
238+
239+
/** @return array<string, array<int, bool|array<int, string>>> */
240+
public static function getGenerateAppliesFilterOnMappedSchemaData(): array
241+
{
242+
return [
243+
'platform without schemas supports' => [false, []],
244+
'platform with schema schemas support' => [true, ['some_schema.table1', 'some_schema.table2']],
245+
];
228246
}
229247

230248
protected function setUp(): void

0 commit comments

Comments
 (0)