Skip to content

ExcelReader incorrectly reading primary key not as integer for Doctrine association #188

@webdevilopers

Description

@webdevilopers

My xlsx has a column Sollkto which will be mapped to my entity property creditAccount

        $converter = new MappingItemConverter();
        $converter
            ->addMapping('Sollkto', 'creditAccount')
        ;

Which is an ManyToOne association:

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\AccountsCode", inversedBy="creditAccountJournals")
     * @ORM\JoinColumn(name="credit_account_id", referencedColumnName="id", nullable=true)
     */
    private $creditAccount;

The value in my xlsx is 135. When reading the row the column in converted into a double: 135.0

Error:
Expected value of type "AppBundle\Entity\AccountsCode" for association field "AppBundle\Entity\Journal#$creditAccount", got "double" instead.

Is this the expected behaviour? It works converting the value via StringToObjectConverter?

$creditAccountConverter = new StringToObjectConverter($creditAccountRepository, 'id');
$workflow->addValueConverter('creditAccount', $creditAccountConverter);

But isn't there an automatic process resp. is the ExcelReader reading a double an issue?

Possibly related:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions