Skip to content

Commit 30d5dee

Browse files
committed
Removing the bc break
1 parent 4a10788 commit 30d5dee

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed

src/Schema/AbstractSchemaManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ protected function _getPortableTableColumnList(string $table, string $database,
817817
try {
818818
$column = $this->_getPortableTableColumnDefinition($row);
819819
} catch (UnknownColumnType $unknownTypeException) {
820-
throw UnknownColumnType::withContext($unknownTypeException->getType(), sprintf('table %s', $table));
820+
throw UnknownColumnType::newWithContext($unknownTypeException->getRequestedType(), $table);
821821
}
822822

823823
$name = strtolower($column->getQuotedName($this->platform));

src/Types/Exception/UnknownColumnType.php

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,52 @@
55
namespace Doctrine\DBAL\Types\Exception;
66

77
use Exception;
8-
use Throwable;
98

109
use function sprintf;
1110

1211
final class UnknownColumnType extends Exception implements TypesException
1312
{
14-
private function __construct(
15-
private string $requestedType,
16-
?string $context,
17-
int $code = 0,
18-
?Throwable $throwable = null,
19-
) {
20-
$message = sprintf(
21-
'Unknown column type "%s" requested%s. Any Doctrine type that you use has '
13+
private string $requestedType;
14+
15+
public function getRequestedType(): string
16+
{
17+
return $this->requestedType;
18+
}
19+
20+
public static function new(string $name): self
21+
{
22+
$object = new self(sprintf(
23+
'Unknown column type "%s" requested. Any Doctrine type that you use has '
2224
. 'to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the '
2325
. 'known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database '
2426
. 'introspection then you might have forgotten to register all database types for a Doctrine Type. '
2527
. 'Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement '
2628
. 'Type#getMappedDatabaseTypes(). If the type name is empty you might '
2729
. 'have a problem with the cache or forgot some mapping information.',
28-
$this->requestedType,
29-
$context !== null ? ' for ' . $context : '',
30-
);
30+
$name,
31+
));
3132

32-
parent::__construct($message, $code, $throwable);
33-
}
33+
$object->requestedType = $name;
3434

35-
public function getType(): string
36-
{
37-
return $this->requestedType;
35+
return $object;
3836
}
3937

40-
public static function new(string $name): self
38+
public static function newWithContext(string $name, string $tableName): self
4139
{
42-
return new self($name, null);
43-
}
40+
$object = new self(sprintf(
41+
'Unknown column type "%s" requested for table "%s". Any Doctrine type that you use has '
42+
. 'to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the '
43+
. 'known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database '
44+
. 'introspection then you might have forgotten to register all database types for a Doctrine Type. '
45+
. 'Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement '
46+
. 'Type#getMappedDatabaseTypes(). If the type name is empty you might '
47+
. 'have a problem with the cache or forgot some mapping information.',
48+
$name,
49+
$tableName,
50+
));
4451

45-
public static function withContext(string $name, string $context): self
46-
{
47-
return new self($name, $context);
52+
$object->requestedType = $name;
53+
54+
return $object;
4855
}
4956
}

tests/Types/Exception/UnknownColumnTypeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function testNew(): void
1313
{
1414
$exception = UnknownColumnType::new('custom_type');
1515

16-
self::assertSame('custom_type', $exception->getType());
16+
self::assertSame('custom_type', $exception->getRequestedType());
1717
self::assertStringContainsString(
1818
'Unknown column type "custom_type" requested.',
1919
$exception->getMessage(),
@@ -22,9 +22,9 @@ public function testNew(): void
2222

2323
public function testWithContext(): void
2424
{
25-
$exception = UnknownColumnType::withContext('custom_type', 'table "some_table"');
25+
$exception = UnknownColumnType::newWithContext('custom_type', 'some_table');
2626

27-
self::assertSame('custom_type', $exception->getType());
27+
self::assertSame('custom_type', $exception->getRequestedType());
2828
self::assertStringContainsString(
2929
'Unknown column type "custom_type" requested for table "some_table".',
3030
$exception->getMessage(),

0 commit comments

Comments
 (0)