pimcore / data-importer

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

[Bug]: Pass an empty value to the As Numeric operator shows wrong preview #359

Closed robertSt7 closed 1 year ago

robertSt7 commented 1 year ago

Expected behavior

Preview show 0

Actual behavior

Preview shows empty

Steps to reproduce

Pass an empty value to the As Numeric operator

kingjia90 commented 1 year ago

I wouldn't consider this as a bug, As Numeric was intended to work the same way as floatval and it is properly documented see: https://github.com/pimcore/data-importer/blob/764dda04a5bfec189f5638b74d941cb4cd1cdcf5/doc/03_Configuration/06_Mapping_Configuration/02_Transformation_Pipeline.md?plain=1#L38C56-L38C64

https://github.com/pimcore/data-importer/blob/764dda04a5bfec189f5638b74d941cb4cd1cdcf5/src/Mapping/Operator/Factory/Numeric.php#L28-L37

Knowing that is_numeric('') or is_numeric(null) that would be false, we wouldn't be returning something "numeric" if it wasn't 0.

Should we introduce a new operator instead that can return null when empty?

dvesh3 commented 1 year ago

Fixed by #363