-
-
Notifications
You must be signed in to change notification settings - Fork 921
feature: improve ids management for association and fix invalid iri/uuid in SearchFilter #1844
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
feature: improve ids management for association and fix invalid iri/uuid in SearchFilter #1844
Conversation
d770734
to
0feb549
Compare
a9a8112
to
5c3183d
Compare
5c3183d
to
1de97f9
Compare
850aa53
to
e6d7809
Compare
@dunglas this needs a review |
I really hope this can be released as bugfix because right now, the searchfilter is just completely useless if your identifier column is not called |
{ | ||
parent::__construct($managerRegistry, $requestStack, $logger, $properties); | ||
|
||
if (null === $identifiersExtractor) { | ||
@trigger_error('Not injecting ItemIdentifiersExtractor is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3.0.', E_USER_DEPRECATED); |
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.
2.1 -> 2.3 ?
Only when the field is an identifier and it's not named |
Sure, all my identifiers are uuids and so I named them |
IMHO, you should do your own filter to support uuid on identifiers. I agree it'll be close to a
|
e6d7809
to
b36ab6b
Compare
I've removed the UUID part. |
src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php
Outdated
Show resolved
Hide resolved
@@ -48,7 +48,6 @@ | |||
</service> | |||
|
|||
<!-- Filter --> | |||
|
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.
to revert
f2d5170
to
c9a8108
Compare
c675488
to
bef4e51
Compare
11b6582
to
f3bb88e
Compare
doing this |
3a7d125
to
34d9e7b
Compare
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.
LGTM
34d9e7b
to
6d657b8
Compare
@@ -389,8 +462,7 @@ Feature: Search filter on collections | |||
"@id": {"pattern": "^/dummies$"}, | |||
"@type": {"pattern": "^hydra:Collection$"}, | |||
"hydra:member": { | |||
"type": "array", | |||
"maxItems": 0 |
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.
Please do not remove this check, but replace it with the right value
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 is because the test was wrong in the first place, an invalid filter should not be applied and therefore should return every items of the collection. We fixed that here.
@@ -66,7 +66,9 @@ | |||
<argument type="service" id="api_platform.iri_converter" /> | |||
<argument type="service" id="api_platform.property_accessor" /> | |||
<argument type="service" id="logger" on-invalid="ignore" /> | |||
<argument key="$identifiersExtractor" type="service" id="api_platform.identifiers_extractor.cached" /> |
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.
<argument key="$identifiersExtractor" type="service" id="api_platform.identifiers_extractor.cached" /> | |
<argument type="service" id="api_platform.identifiers_extractor.cached" on-invalid="ignore" /> |
@@ -55,6 +55,7 @@ | |||
<argument type="service" id="api_platform.iri_converter" /> | |||
<argument type="service" id="api_platform.property_accessor" /> | |||
<argument type="service" id="logger" on-invalid="ignore" /> | |||
<argument key="$identifiersExtractor" type="service" id="api_platform.identifiers_extractor.cached" /> |
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.
<argument key="$identifiersExtractor" type="service" id="api_platform.identifiers_extractor.cached" /> | |
<argument type="service" id="api_platform.identifiers_extractor.cached" on-invalid="ignore" /> |
@@ -20,37 +20,62 @@ Feature: Search filter on collections | |||
When I send a "GET" request to "/dummy_cars?colors.prop=red" | |||
Then the response status code should be 200 | |||
And the JSON should be deep equal to: | |||
""" | |||
""" |
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.
Tab indent instead of spaces
@@ -344,15 +345,6 @@ public function provideApplyTestData(): array | |||
], | |||
], | |||
], | |||
[ | |||
'$match' => [ |
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.
Why did you remove this block of test result?
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.
Same reason as above.
@@ -469,17 +461,7 @@ public function provideApplyTestData(): array | |||
$filterFactory, | |||
], | |||
'invalid value for relation' => [ | |||
[ | |||
[ | |||
'$match' => [ |
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.
Same
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.
Same reason as above.
{ | ||
parent::__construct($managerRegistry, $logger, $properties); | ||
|
||
if (null === $identifiersExtractor) { | ||
@trigger_error('Not injecting ItemIdentifiersExtractor is deprecated since API Platform 2.5 and can lead to unexpected behaviors, it will not be possible anymore in API Platform 3.0.', E_USER_DEPRECATED); |
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.
Mongo is marked as @experimental
. Not sure BC is relevant here...
This PRs update the ids management for association in the SearchFilter.
I've not updated the single at the moment because I think it should be done in another PR.
This fixes #775.
Something I'm not sure is the behaviour, do we ignore the filter (this is the current implementation) or do we return 0 elements (like by replacing the invalid values with null instead of logging + return) ?