-
-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Labels
Description
I am using postgres13, php8.4 and the latest version of this package.
When writing an array of type TextArray: ["1", "test"] the values will be converted to {"1","test"}
When saving, postgresql will save them as: {1,test} because escaping is redundant in this case.
PostgresArrayToPHPArrayTransformer::transformPostgresArrayToPHPArray will return the value [1, "test"] having lost the original type of item.
I used a quick fix to solve the problem, but I think it should be fixed at the PostgresArrayToPHPArrayTransformer level by limiting the return types (cast to string for TextArray type).
use MartinGeorgiev\Doctrine\DBAL\Types\TextArray as BaseType;
class TextArray extends BaseType
{
protected function transformFromPostgresTextArray(string $postgresValue): array
{
$values = parent::transformFromPostgresTextArray($postgresValue);
foreach ($values as $key => $value) {
if (!is_string($value)) {
$values[$key] = (string) $value;
}
}
return $values;
}
}