Skip to content

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

Conversation

Simperfit
Copy link
Contributor

@Simperfit Simperfit commented Apr 11, 2018

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets #775
License MIT
Doc PR

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) ?

@Simperfit Simperfit force-pushed the feature/improve-ids-management-for-association branch 3 times, most recently from d770734 to 0feb549 Compare April 11, 2018 10:29
@Simperfit Simperfit changed the title Feature/improve ids management for association feature: improve ids management for association and fix invalid iri/uuid in SearchFilter Apr 11, 2018
@Simperfit Simperfit force-pushed the feature/improve-ids-management-for-association branch 4 times, most recently from a9a8112 to 5c3183d Compare April 11, 2018 13:28
@Simperfit Simperfit force-pushed the feature/improve-ids-management-for-association branch from 5c3183d to 1de97f9 Compare April 11, 2018 15:31
@Simperfit Simperfit force-pushed the feature/improve-ids-management-for-association branch 2 times, most recently from 850aa53 to e6d7809 Compare April 12, 2018 10:02
@Simperfit
Copy link
Contributor Author

@dunglas this needs a review

@Toflar
Copy link
Contributor

Toflar commented Apr 30, 2018

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 id 😢

{
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.1 -> 2.3 ?

@soyuka
Copy link
Member

soyuka commented Apr 30, 2018

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 id cry

Only when the field is an identifier and it's not named id 😄 (who would do that seriously ?! /s)

@Toflar
Copy link
Contributor

Toflar commented Apr 30, 2018

Sure, all my identifiers are uuids and so I named them uuid instead of id but I could change that.

@soyuka
Copy link
Member

soyuka commented Apr 30, 2018

Sure, all my identifiers are uuids and so I named them uuid instead of id but I could change that.

IMHO, you should do your own filter to support uuid on identifiers. I agree it'll be close to a copy/paste of the current SearchFilter but I don't think it's a bad idea. It kinda joins the idea I had above (and could maybe be proposed as a new feature for upcoming releases):

  • FieldSearchFilter (handles LIKE and such where clauses)
  • IdentifierSearchFilter (handles strict equalities, IRIs and everything related to identifiers (foo.bar=id). This one would reuse the identifier denormalization introduced a few weeks back).

@Simperfit Simperfit force-pushed the feature/improve-ids-management-for-association branch from e6d7809 to b36ab6b Compare May 3, 2018 07:56
@Simperfit
Copy link
Contributor Author

I've removed the UUID part.

@@ -48,7 +48,6 @@
</service>

<!-- Filter -->

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to revert

@Simperfit Simperfit force-pushed the feature/improve-ids-management-for-association branch 2 times, most recently from f2d5170 to c9a8108 Compare May 4, 2018 13:23
@meyerbaptiste meyerbaptiste force-pushed the feature/improve-ids-management-for-association branch 5 times, most recently from c675488 to bef4e51 Compare May 4, 2018 14:40
@Simperfit Simperfit force-pushed the feature/improve-ids-management-for-association branch 2 times, most recently from 11b6582 to f3bb88e Compare May 9, 2018 09:59
@Simperfit Simperfit requested a review from dunglas May 9, 2018 10:58
@soyuka
Copy link
Member

soyuka commented Apr 6, 2019

doing this EU-FOSSA Hackathon

@soyuka soyuka force-pushed the feature/improve-ids-management-for-association branch 5 times, most recently from 3a7d125 to 34d9e7b Compare April 6, 2019 14:03
Copy link
Contributor

@antograssiot antograssiot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@soyuka soyuka force-pushed the feature/improve-ids-management-for-association branch from 34d9e7b to 6d657b8 Compare April 6, 2019 15:17
@soyuka soyuka merged commit 8f57f08 into api-platform:master Apr 6, 2019
@@ -389,8 +462,7 @@ Feature: Search filter on collections
"@id": {"pattern": "^/dummies$"},
"@type": {"pattern": "^hydra:Collection$"},
"hydra:member": {
"type": "array",
"maxItems": 0
Copy link
Contributor

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

Copy link
Member

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" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<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" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<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:
"""
"""
Copy link
Contributor

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' => [
Copy link
Contributor

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?

Copy link
Member

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' => [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reason as above.

@vincentchalamon vincentchalamon mentioned this pull request Apr 6, 2019
{
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);
Copy link
Member

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug ? Get collection with filters and several IRI
6 participants