-
Notifications
You must be signed in to change notification settings - Fork 27
Description
In some cases, when using a composite field type and PgEntity converter, a nullable field will be converted to an empty string. This is the case when the nullable field is a string type like varchar, text, uuid, ...
The problem is that PgEntity uses str_getcsv to split the composite row value, essential like this
$data = '28c2cf5f-4df9-4e6f-a5d6-a41eaba35285,"test","",';
$values = str_getcsv($data);
foreach ($values as $val) {
var_dump($val) . PHP_EOL;
}Unfortunately this will return an empty string, where it should not be.
string(36) "28c2cf5f-4df9-4e6f-a5d6-a41eaba35285"
string(4) "test"
string(0) ""
string(0) ""Depending on the type declared in the RowStructure definition, an empty string may be interpreted as null value within the hydration plan (e.g. in case of boolean, numeric, int, ...), but it is not possible to determine the correct value for string types just from the empty string.
As PgComposite also uses str_getcsv I would assume the same behaviour for that converter. But I've not tested that.
Any idea how to avoid str_getcsv?