Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression caused by e369cb6 #9849

Open
asimonf opened this issue Jun 15, 2022 · 1 comment
Open

Regression caused by e369cb6 #9849

asimonf opened this issue Jun 15, 2022 · 1 comment

Comments

@asimonf
Copy link

asimonf commented Jun 15, 2022

Bug Report

Q A
BC Break yes
Version 2.12.*

Summary

I have an inheritance tree using joined tables where a version field for optimistic locking exists for a subclass, but not in the parent. Whenever I try to insert, it fails after executing this query:

SELECT versionLock FROM Car WHERE id = '...';

The exception message is 'Unexpected empty result for database query.'

Current behavior

When using Version for optimistic locking in JOINED subclasses, the refresh fails on new inserts since the inserted version does not exist on the parent subclass, yet it tries to refresh the subclass.

The exception is triggered on the BasicEntityPersister.php file here:

        $values = $this->conn->fetchNumeric(
            $sql,
            array_values($flatId),
            $this->extractIdentifierTypes($id, $versionedClass)
        );

        if ($values === false) {
            throw new LengthException('Unexpected empty result for database query.');
        }

How to reproduce

Create an inheritance tree. The parent class must define a JOINED inheritance type and a child class must declare a field with the Version annotation. Afterwards, try to insert a child object into the database. This happens with numeric "version" that have a default value assigned by the database engine.

Expected behavior

That the child is inserted properly.

@greg0ire greg0ire changed the title Regression caused by #e369cb6 Regression caused by e369cb6 Jun 15, 2022
@greg0ire
Copy link
Member

Link: e369cb6

asimonf added a commit to asimonf/orm that referenced this issue Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants