Skip to content
Closed
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
14 changes: 0 additions & 14 deletions src/MartinGeorgiev/Utils/DataStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,6 @@ public static function transformPostgresTextArrayToPHPArray(string $postgresArra
break;
}

$isInteger = \is_numeric($text) && ''.(int) $text === $text;
if ($isInteger) {
$phpArray[$i] = (int) $text;

continue;
}

$isFloat = \is_numeric($text) && ''.(float) $text === $text;
if ($isFloat) {
$phpArray[$i] = (float) $text;

continue;
}

if (!\is_string($text)) {
$exceptionMessage = 'Unsupported data type encountered. Expected null, integer, float or string value. Instead it is "%s".';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Error message mentions expecting integer/float values but code no longer handles these types


Expand Down
8 changes: 4 additions & 4 deletions tests/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function provideValidTransformations(): array
],
[
'phpValue' => [
1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed?

'1',
'2',
'text',
'some text here',
Expand All @@ -67,7 +67,7 @@ public static function provideValidTransformations(): array
*/
public function has_name(): void
{
$this->assertEquals('text[]', $this->fixture->getName());
$this->assertSame('text[]', $this->fixture->getName());
}

/**
Expand All @@ -77,7 +77,7 @@ public function has_name(): void
*/
public function can_transform_from_php_value(?array $phpValue, ?string $postgresValue): void
{
$this->assertEquals($postgresValue, $this->fixture->convertToDatabaseValue($phpValue, $this->platform));
$this->assertSame($postgresValue, $this->fixture->convertToDatabaseValue($phpValue, $this->platform));
}

/**
Expand All @@ -87,6 +87,6 @@ public function can_transform_from_php_value(?array $phpValue, ?string $postgres
*/
public function can_transform_to_php_value(?array $phpValue, ?string $postgresValue): void
{
$this->assertEquals($phpValue, $this->fixture->convertToPHPValue($postgresValue, $this->platform));
$this->assertSame($phpValue, $this->fixture->convertToPHPValue($postgresValue, $this->platform));
}
}
6 changes: 3 additions & 3 deletions tests/MartinGeorgiev/Utils/DataStructureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function provideValidTransformations(): array
0 => 'dfasdf',
1 => 'qw,,e{q"we',
2 => "'qrer'",
3 => 604,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed?

3 => '604',
4 => '"aaa","b""bb","ccc"',
],
'postgresValue' => '{"dfasdf","qw,,e{q\"we","\'qrer\'",604,"\"aaa\",\"b\"\"bb\",\"ccc\""}',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Mismatch between test data - phpValue has '604' as string but postgresValue has 604 as unquoted number. This will cause type inconsistency.

Expand Down Expand Up @@ -71,7 +71,7 @@ public static function provideValidTransformations(): array
*/
public function can_transform_from_php_value(array $phpValue, string $postgresValue): void
{
$this->assertEquals($postgresValue, DataStructure::transformPHPArrayToPostgresTextArray($phpValue));
$this->assertSame($postgresValue, DataStructure::transformPHPArrayToPostgresTextArray($phpValue));
}

/**
Expand All @@ -83,7 +83,7 @@ public function can_transform_from_php_value(array $phpValue, string $postgresVa
*/
public function can_transform_to_php_value(array $phpValue, string $postgresValue): void
{
$this->assertEquals($phpValue, DataStructure::transformPostgresTextArrayToPHPArray($postgresValue));
$this->assertSame($phpValue, DataStructure::transformPostgresTextArrayToPHPArray($postgresValue));
}

/**
Expand Down
Loading