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

allow ManyToMany associations with referenced column name different from 'id' #631

Open
wants to merge 3 commits into
base: 1.x
Choose a base branch
from

Conversation

awm1
Copy link

@awm1 awm1 commented Jul 25, 2024

Subject

I've found out that if I want to audit entity with ID column with name different from 'id' :

class User
{
/**
* @Orm\Id()
* @Orm\Column(name="user_name",type="string")
/
private $userName;
/
*
* @Orm\ManyToMany(targetEntity="AppBundle\Entity\Department", inversedBy="members", cascade={"persist"})
* @Orm\JoinTable(
* name="systemusers_department_membership",
* joinColumns={@Orm\JoinColumn(name="systemusers_id", referencedColumnName="user_name")},
* inverseJoinColumns={@Orm\JoinColumn(name="department_id", referencedColumnName="id")}
* )
*/
private $departmentMembership;
}

...those ManyToMany assoc isn't referred by its correct identifier name, but static 'id' string which will throw Exception. So I try to get it from available source, however I'm not sure if this is the right way to obtain it. I am targeting 1.x branch because this is simple fix which should not break anything.

Changelog

### Fixed
Accessing ManyToMany associations of audited entity with identity field of name different from 'id'.  

Copy link
Member

@phansys phansys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @awm1!

Please, add a test covering this fix.

src/AuditReader.php Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants