Regression caused by e369cb6 #6992

Open
opened 2026-01-22 15:42:45 +01:00 by admin · 1 comment
Owner

Originally created by @asimonf on GitHub (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.

Originally created by @asimonf on GitHub (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 <!-- What is the current (buggy) 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.
Author
Owner

@greg0ire commented on GitHub (Jun 15, 2022):

Link: e369cb6

@greg0ire commented on GitHub (Jun 15, 2022): Link: e369cb6
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6992