-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
Unexpected return value #43
Comments
It isn’t enough to set the column type to “uuid,” since that will use Doctrine’s internal UUID generator, which is string-based. If you’d like to use ramsey/uuid, you need more annotations:
The custom strategy and generator class references are important to get Doctrine to return a Uuid object, instead of string. |
I've just tried it out, changing the annotations does not fix the issue, i still get
|
What happens when you ditch chaining and declare owner as a variable? |
This is a known issue of Doctrine currently. When creating a proxy object (which is the case here for the owner), type conversions are not properly applied. This is why the id is returned as a string before initialization (it works fine after initialization due to the initialization setting all properties from the loaded data with the right type, including the id). |
Ok thanks for confirming @stof. |
Hello,
I've encountered some unexpected behaviour using UUID's and doctrine relations:
Lets say I have the 2 following classes
Car
Person
Using it as follows errors with: Expected return type of UUID, string returned
The following does work
From what I understand, It returns a string because doctrine will create a 'proxy' with the id pre-filled until a property is accessed and the entity 'initialised'.
I could add the following in the getId() method:
But this kinda beats the purpose of types.
So my questions are:
The text was updated successfully, but these errors were encountered: