[PR #6759] Inverse side of OneToOne is loaded without identifier condition #10128

Open
opened 2026-01-22 16:06:31 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/6759

State: closed
Merged: No


When testing of 2.6.x-dev, I found out that under certain conditions is inverse side of OneToOne relation loaded without any SQL condition - whith results in loading first row returned by database and possibly corrupted data.

Condition when this occurs are:

  • Have bidirectional 1-1 relation
  • Have relation column named same as entity field (eg. @JoinColumn(name="field"))
  • Load entity on inverse side via DQL query (issue does not occur with em->find)

=> 💥 Mapping side of the realtion will be loaded with second SQL query, but WHERE condition is missing

Attached is failing test case illustration the issue.

Bug is probably caused by a360da5a7e

**Original Pull Request:** https://github.com/doctrine/orm/pull/6759 **State:** closed **Merged:** No --- When testing of 2.6.x-dev, I found out that under certain conditions is inverse side of OneToOne relation loaded without **any SQL condition** - whith results in loading first row returned by database and possibly corrupted data. Condition when this occurs are: - Have bidirectional 1-1 relation - Have relation column named same as entity field (eg. `@JoinColumn(name="field")`) - Load entity on inverse side via DQL query (issue does not occur with em->find) => 💥 Mapping side of the realtion will be loaded with second SQL query, but WHERE condition is missing **Attached is failing test case illustration the issue.** Bug is probably caused by https://github.com/doctrine/doctrine2/commit/a360da5a7e5463f6c12b0922f6063e1cf32dde6d
admin added the pull-request label 2026-01-22 16:06:31 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#10128