Skip to content

Commit 146e643

Browse files
committed
Implement getMappedDatabaseTypes()
1 parent fcd0124 commit 146e643

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/Types/GeometryType.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use function is_resource;
2020
use function sprintf;
2121
use function stream_get_contents;
22+
use function strtolower;
2223

2324
/**
2425
* Doctrine type for Geometry.
@@ -137,6 +138,20 @@ protected function hasKnownSubclasses(): bool
137138
return true;
138139
}
139140

141+
#[\Override]
142+
public function getMappedDatabaseTypes(AbstractPlatform $platform): array
143+
{
144+
if ($platform instanceof AbstractMySQLPlatform) {
145+
return [strtolower($this->getGeometryName())];
146+
}
147+
148+
if ($platform instanceof PostgreSQLPlatform && static::class === self::class) {
149+
return ['geometry'];
150+
}
151+
152+
return [];
153+
}
154+
140155
protected function getGeometryName(): string
141156
{
142157
return 'Geometry';

tests/FunctionalTestCase.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Doctrine\Common\DataFixtures\Loader;
1111
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
1212
use Doctrine\DBAL\Connection;
13-
use Doctrine\DBAL\Platforms\AbstractPlatform;
1413
use Doctrine\ORM\EntityManager;
1514
use Doctrine\ORM\ORMSetup;
1615
use Doctrine\ORM\Tools\SchemaTool;
@@ -21,8 +20,6 @@
2120
*/
2221
abstract class FunctionalTestCase extends TestCase
2322
{
24-
private AbstractPlatform $platform;
25-
2623
private Loader $fixtureLoader;
2724

2825
private EntityManager $em;
@@ -36,15 +33,6 @@ protected function setUp(): void
3633
parent::setUp();
3734

3835
$this->connection = createDoctrineConnection(selectDatabase: true);
39-
$this->platform = $this->connection->getDatabasePlatform();
40-
41-
$this->platform->registerDoctrineTypeMapping('geometry', 'binary');
42-
$this->platform->registerDoctrineTypeMapping('linestring', 'binary');
43-
$this->platform->registerDoctrineTypeMapping('multilinestring', 'binary');
44-
$this->platform->registerDoctrineTypeMapping('multipoint', 'binary');
45-
$this->platform->registerDoctrineTypeMapping('multipolygon', 'binary');
46-
$this->platform->registerDoctrineTypeMapping('point', 'binary');
47-
$this->platform->registerDoctrineTypeMapping('polygon', 'binary');
4836

4937
$this->fixtureLoader = new Loader();
5038

0 commit comments

Comments
 (0)