Skip to content

Problem with UPDATE on DATE primary key #676

@jkavalik

Description

@jkavalik

Hello @hrach , today I stumbled onto another instance of the problem we already discussed in #320 when using

nextras/dbal	v4.0.5
nextras/orm	v4.0.7

Seems that \Nextras\Orm\Mapper\Dbal\DbalMapper::persist() was not fixed and it still contains

$id = (array) $entity->getPersistedId();

which converts the Datetime instance into 3-item array and then tries to use the first part (string) as the PK and fails with Modifier %?dts expects value to be DateTime, string given. again.

I was able to fix it locally with

$id = (array) $entity->getPersistedId();
if ($entity->getPersistedId() instanceof \DateTimeInterface) {
    $id = [$entity->getPersistedId()];
}

I can prepare a pull request with that change in persist(), processMySQLAutoupdate() and remove() if it helps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions