pimcore / data-importer

This extension adds a comprehensive import functionality to Pimcore Datahub.
Other
38 stars 56 forks source link

[Bug]: AsDate should always return Carbon or null #388

Closed morgannilsson closed 7 months ago

morgannilsson commented 7 months ago

Expected behavior

If input is empty string, null should be returned.

Actual behavior

The empty string is returned.

Steps to reproduce

Use Transformation Pipeline As Date. Import empty string.

Pimcore\Bundle\DataImporterBundle\Mapping\Operator\Factory\Date.php (around line:50):

should read:

    foreach ($inputData as &$data) {
        if (!empty($data)) {
            $data = \Carbon\Carbon::createFromFormat($this->format, $data);
        } else {
            $data = null;
    }
fashxp commented 7 months ago

could you please provide a PR. thx.

morgannilsson commented 7 months ago

DataImport_Transform_Date.patch

morgannilsson commented 7 months ago

391

morgannilsson commented 7 months ago

I am working on setting up a devenv for pimcore github. Will add a test case later.