ddeboer / data-import

Import data from and export data to a range of different file formats and media
MIT License
567 stars 123 forks source link

DoctrineWriter->UpdateEntity doesn't nullify entity properties #303

Open sergis opened 8 years ago

sergis commented 8 years ago

In case of update existing doctrine entity I cannot nullify target property even if it exists but set empty in importing item. the most annoying case is for datetime item values :( I suppose the following statement in DoctrineWriter->UpdateEntity()

            if (isset($item[$fieldName])) {
                $value = $item[$fieldName];
            } elseif (method_exists($item, 'get' . ucfirst($fieldName))) {
                $value = $item->{'get' . ucfirst($fieldName)};
            }
            if (null === $value) {
                continue;
            }

should be replaced to

            if (array_key_exists($fieldName,$item)) {
                $value = $item[$fieldName];
            } elseif (method_exists($item, 'get' . ucfirst($fieldName))) {
                $value = $item->{'get' . ucfirst($fieldName)};
            } else {
           continue;
         }

Would you please explain if I'm wrong for some reasons?