-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Support native enum hydration when using NEW
operator
#9936
Conversation
02e054a
to
015cae5
Compare
$result = $this->_em->createQueryBuilder() | ||
->from(Card::class, 'c') | ||
->select(new Func('NEW ' . DtoWithEnum::class, ['c.suit'])) | ||
->getQuery() | ||
->getResult(); | ||
|
||
$this->assertInstanceOf(Suit::class, $result[0]->suit); | ||
$this->assertEquals(Suit::Clubs, $result[0]->suit); | ||
|
||
$result = $this->_em->createQueryBuilder() | ||
->from(CardWithNullable::class, 'c') | ||
->select(new Func('NEW ' . DtoWithEnum::class, ['c.suit'])) | ||
->getQuery() | ||
->getResult(); | ||
|
||
$this->assertNull($result[0]->suit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are actually two separate test cases. Please split them up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. 👍
As it was inspired by a test case above, I modified it as well.
015cae5
to
3d12fca
Compare
Code looks good so far from my POV. Could you please write the tests using SQL for the NEW operator? Something like |
Using the `NEW` operator with the query builder now properly converts scalar values to native enums inside data transfer objects.
3d12fca
to
5d434c8
Compare
Sure 🙂 |
Cool. 🙂 |
* 2.13.x: Address DBAL 3.4 deprecations (doctrine#9969) Improve phpdoc for ClassMetadataInfo (doctrine#9965) Fix build (doctrine#9964) fix: class normalisation test (doctrine#9966) Support native enum hydration when using `NEW` operator (doctrine#9936)
Using the
NEW
operator with the query builder now properly convertsscalar values to native enums inside data transfer objects.