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
Handle binary UUID in SearchFilter #3774
Conversation
Since it's a bugfix, it should target 2.5. |
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.
I used a less generic parameter name ... Tell me if it's the right way to do.
Nice patch, please target 2.5 |
Updated to use QueryNameGenerator for variable names. |
for ($i = 0; $i < $nbArgs; ++$i) { | ||
$inQuery[] = ':filterproperty'.$i; | ||
$parameters->add(new Parameter('filterproperty'.$i, $caseSensitive ? $values[$i] : strtolower($values[$i]), $type)); | ||
$args = []; |
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.
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.
This will require updating some tests expectations because when multiple values are given, they are set as one unique array parameter, and that will become several parameters. See https://github.com/api-platform/core/pull/3774/checks?check_run_id=1379433208#step:14:91
I'm currently blocked at adding UUID tests, I cant fully understand yet how tests are organized and how can I add custom types.
\Doctrine\DBAL\Types\Type::addType('uuid', \Ramsey\Uuid\Doctrine\UuidType::class);
is required to manipulate uuid types.
80f3204
to
bf34b36
Compare
I've pushed an attempt to add test on UUID field, but the current test failed because |
if you need more help @odoucet ping me on symfony's slack! |
I'll update my PR with latest master branch in a few days. |
129a912
to
76ec314
Compare
Hello, |
aa50420
to
83d4dfa
Compare
4ded0f9
to
16dd558
Compare
16dd558
to
a1f12ca
Compare
Hello @odoucet, |
Thank you @odoucet. |
This reverts commit ff248ae.
This reverts commit ff248ae.
This reverts commit ff248ae.
When searching on a binary UUID field, current behaviour leads to search done on Doctrine with the string UUID and not the binary version of it.
This is because the field type must be provided to Doctrine each time we use QueryBuilder. Why ? Because Doctrine sees string on input, and does not know it needs conversion.
This PR reads
$metadata->getTypeOfField()
and force field type.WARNING
Current PR passes the unit tests (so it does not break current behaviour), but does not implement two new needed tests (to make sure it fixes the issue mentioned) :
Test has been done on a local project so I know it works, but better to check this with a test :)
I need some help adding custom type to SearchFilterTestTrait as
uuidBinary
is not recognized.