Incorrect Error During Schema Validation #7137

Closed
opened 2026-01-22 15:45:25 +01:00 by admin · 3 comments
Owner

Originally created by @danfoley on GitHub (Apr 22, 2023).

Bug Report

Q A
BC Break no
Version 2.14.2.0

Summary

Running doctrine orm:validate-schema gives validation errors that don't exist.

Current behavior

Running doctrine orm:validate-schema gives the follow 2 errors:

[FAIL] The entity-class Messenger\Domain\Unit mapping is invalid:
 The field Messenger\Domain\Unit#residents is on the inverse side of a bi-directional relationship, 
 but the specified mappedBy association on the target-entity Messenger\Domain\Person#units 
 does not contain the required 'inversedBy="residents"' attribute.

 [FAIL] The entity-class Messenger\Domain\Group mapping is invalid:
 The field Messenger\Domain\Group#members is on the inverse side of a bi-directional relationship, 
 but the specified mappedBy association on the target-entity Messenger\Domain\Person#groups 
 does not contain the required 'inversedBy="members"' attribute.

When the inversedBy attributes do exist in the XML mapping.

How to reproduce

use following xml schema

<entity name="Messenger\Domain\Person" table="person" change-track-policy="DEFERRED_EXPLICIT">
  <field name="firstName" type="string" column="first_name" />
  <field name="lastName" type="string" column="last_name" />
  <field name="email" type="string" column="email" />
    <many-to-many field="units" inversed-by="residents" target-entity="Messenger\Domain\Unit">
    </many-to-many>
    <many-to-many field="groups" inversed-by="members" target-entity="Messenger\Domain\Group">
    </many-to-many>
    <attribute-override name="id">
    <field column="person_id" />
  </attribute-override>
</entity>

<entity name="Messenger\Domain\Unit" table="unit" change-track-policy="DEFERRED_EXPLICIT">
  <id name="id" type="uuid" column="id" />
  <field name="name" type="string" column="name" />
  <many-to-many field="residents"
          target-entity="Messenger\Domain\Person"
          mapped-by="units">
  </many-to-many>
 </entity>
    
 <entity name="Messenger\Domain\Group" table="group" change-track-policy="DEFERRED_EXPLICIT">
  <attribute-override name="id">
    <field column="group_id" />
  </attribute-override>
  <field name="name" type="string" column="name" />
    <many-to-many field="members"
        target-entity="Messenger\Domain\Person"
        mapped-by="groups">
    </many-to-many>
</entity>

Expected behavior

The xml mapping should be reported as valid.

Originally created by @danfoley on GitHub (Apr 22, 2023). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | no | Version | 2.14.2.0 #### Summary Running doctrine orm:validate-schema gives validation errors that don't exist. <!-- Provide a summary describing the problem you are experiencing. --> #### Current behavior Running doctrine orm:validate-schema gives the follow 2 errors: ``` [FAIL] The entity-class Messenger\Domain\Unit mapping is invalid: The field Messenger\Domain\Unit#residents is on the inverse side of a bi-directional relationship, but the specified mappedBy association on the target-entity Messenger\Domain\Person#units does not contain the required 'inversedBy="residents"' attribute. [FAIL] The entity-class Messenger\Domain\Group mapping is invalid: The field Messenger\Domain\Group#members is on the inverse side of a bi-directional relationship, but the specified mappedBy association on the target-entity Messenger\Domain\Person#groups does not contain the required 'inversedBy="members"' attribute. ``` When the inversedBy attributes do exist in the XML mapping. <!-- What is the current (buggy) behavior? --> #### How to reproduce use following xml schema ``` xml <entity name="Messenger\Domain\Person" table="person" change-track-policy="DEFERRED_EXPLICIT"> <field name="firstName" type="string" column="first_name" /> <field name="lastName" type="string" column="last_name" /> <field name="email" type="string" column="email" /> <many-to-many field="units" inversed-by="residents" target-entity="Messenger\Domain\Unit"> </many-to-many> <many-to-many field="groups" inversed-by="members" target-entity="Messenger\Domain\Group"> </many-to-many> <attribute-override name="id"> <field column="person_id" /> </attribute-override> </entity> <entity name="Messenger\Domain\Unit" table="unit" change-track-policy="DEFERRED_EXPLICIT"> <id name="id" type="uuid" column="id" /> <field name="name" type="string" column="name" /> <many-to-many field="residents" target-entity="Messenger\Domain\Person" mapped-by="units"> </many-to-many> </entity> <entity name="Messenger\Domain\Group" table="group" change-track-policy="DEFERRED_EXPLICIT"> <attribute-override name="id"> <field column="group_id" /> </attribute-override> <field name="name" type="string" column="name" /> <many-to-many field="members" target-entity="Messenger\Domain\Person" mapped-by="groups"> </many-to-many> </entity> ``` <!-- Provide steps to reproduce the bug. If possible, also add a code snippet with relevant configuration, entity mappings, DQL etc. Adding a failing Unit or Functional Test would help us a lot - you can submit one in a Pull Request separately, referencing this bug report. --> #### Expected behavior The xml mapping should be reported as valid. <!-- What was the expected (correct) behavior? -->
admin closed this issue 2026-01-22 15:45:25 +01:00
Author
Owner

@danfoley commented on GitHub (Apr 22, 2023):

Duplicate issue here: https://github.com/doctrine/orm/issues/7198

@danfoley commented on GitHub (Apr 22, 2023): Duplicate issue here: https://github.com/doctrine/orm/issues/7198
Author
Owner

@greg0ire commented on GitHub (Apr 22, 2023):

Possible next steps: contribute a failing test from the example above.

@greg0ire commented on GitHub (Apr 22, 2023): Possible next steps: contribute a failing test from the example above.
Author
Owner

@greg0ire commented on GitHub (Apr 22, 2023):

Let's close since it is a duplicate? If you have more things to add, add them directly in #7198 please.

@greg0ire commented on GitHub (Apr 22, 2023): Let's close since it is a duplicate? If you have more things to add, add them directly in #7198 please.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7137