Active
Project:
Drupal core
Version:
main
Component:
jsonapi.module
Priority:
Minor
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
8 May 2018 at 09:05 UTC
Updated:
3 Apr 2020 at 21:56 UTC
Jump to comment: Most recent
See #2958587-19: Unable to filter on columns of entity reference fields.1:
+++ b/src/Context/FieldResolver.php @@ -320,4 +352,93 @@ class FieldResolver { + $message = sprintf('Ambiguous path. Try one of the following: %s, before the given path: %s', $choices, $given); + throw new BadRequestHttpException($message);There's no explicit test coverage for this yet.
And reply in #21:
There's no explicit test coverage for this yet. Having that would also help address #18.6.
Without a custom field type, this isn't possible to test. I'm happy to remove the logic, make a follow-up issue and hard-code the word
entityin the method for now. What do you think? Add the robust logic now, without a test, or have a hardcoded value now with a follow-up and test?
We went with Add the robust logic now, without a test
. This issue is for adding the test.
Comments
Comment #2
wim leersComment #3
wim leers@gabesullice indicated in #2953207-32: Can't get the right target type when filtering on relationship with bundle-specific target entity type that this issue should also test that, and perhaps that's a use case that won't require a custom field type.
Comment #4
wim leersComment #5
wim leersIt'd be great to add test coverage for this before it goes into core.
Comment #6
wim leersRetitling to be consistent with other similar (test coverage) issues.
Comment #7
wim leersThe code quoted above that is in need of test coverage is now called less often as of #3010432: Filtering by referenced entity requires ".uuid" to be specified in filter path expression. That did add explicit tests. And that now explicitly does not call
getDataReferencePropertyName()if there are no reference properties in existence; and we even have explicit test coverage that verifies you get useful errors:\Drupal\Tests\jsonapi\Kernel\Query\FilterTest::testInvalidFilterPathDueToNonexistentProperty(),\Drupal\Tests\jsonapi\Kernel\Query\FilterTest::testInvalidFilterPathDueToMissingPropertyNameReferenceFieldWithMetaProperties()and so on.So this bit from #2958587-10: Unable to filter on columns of entity reference fields:
is now mitigated much more than it already was by #2958587 before.
But the test coverage advocated for here is still necessary, because it's specifically for the case where we have >=2 candidate fields to resolve a filter expression, >=1 where the
DataReferenceDefinitionproperty is namedentityAND one where it is not namedentity.That is a fairly extreme edge case though, so demoting priority.
Comment #8
rpayanmMoving to Drupal core's issue queue.
I'm working on https://www.drupal.org/project/drupal/issues/3122113