Skip to content

Commit

Permalink
Make all mapped database types case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
Rainrider committed Mar 2, 2024
1 parent 00d8f60 commit beeb86e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ private function initializeAllDoctrineTypeMappings(): void

foreach (Type::getTypesMap() as $typeName => $className) {
foreach (Type::getType($typeName)->getMappedDatabaseTypes($this) as $dbType) {
$dbType = strtolower($dbType);
$this->doctrineTypeMapping[$dbType] = $typeName;
}
}
Expand Down
34 changes: 34 additions & 0 deletions tests/Platforms/AbstractPlatformTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,40 @@ public function testRegisterDoctrineMappingType(): void
self::assertEquals(Types::INTEGER, $this->platform->getDoctrineTypeMapping('foo'));
}

public function testCaseInsensitiveDoctrineTypeMappingFromType(): void
{
$type = new class () extends Type {
/**
* {@inheritDoc}
*/

Check failure on line 114 in tests/Platforms/AbstractPlatformTestCase.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.2)

Function get_class() should not be referenced via a fallback global name, but via a use statement.

Check failure on line 114 in tests/Platforms/AbstractPlatformTestCase.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.2)

Class name referenced via call of function get_class().
public function getMappedDatabaseTypes(AbstractPlatform $platform): array
{

Check failure on line 116 in tests/Platforms/AbstractPlatformTestCase.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.2)

Function get_class() should not be referenced via a fallback global name, but via a use statement.

Check failure on line 116 in tests/Platforms/AbstractPlatformTestCase.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.2)

Class name referenced via call of function get_class().
return ['TESTTYPE'];
}

public function getName(): string
{
return 'testtype';
}

/**
* {@inheritDoc}
*/
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
return $platform->getDecimalTypeDeclarationSQL($column);
}
};

if (Type::hasType($type->getName())) {
Type::overrideType($type->getName(), get_class($type));
} else {
Type::addType($type->getName(), get_class($type));
}

self::assertSame($type->getName(), $this->platform->getDoctrineTypeMapping('TeStTyPe'));
}

public function testRegisterUnknownDoctrineMappingType(): void
{
$this->expectException(Exception::class);
Expand Down

0 comments on commit beeb86e

Please sign in to comment.