mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Method getId() in generated proxy class casts to int, conflicts with enum primary key #7193
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pauljura on GitHub (Jul 31, 2023).
Bug Report
Summary
The generated proxy class for an entity has the following code for the getId() method:
The problem is the line with
return (int) parent::getId();because it's hardcoded to cast the return value to int, even though the method is expected to return an enum class.Current behavior
An error is thrown:
How to reproduce
To reproduce this, you need:
Expected behavior
The getId() method should return the correct enum class instead of an int.
Probably just removing the
(int)should fix it.Workaround
Avoid using the proxy by using eager loading, or fetching some other property to initialize the object.