I am trying to filter my content and by accident used "IS" instead of "IN" in my filter conditions:
?filter[field_gender][operator]=IN&filter[field_gender][value]=Male&filter[field_character_type][operator]=IS&filter[field_character_type][value]=...-b0bc4e9feb85

That ended up in a 500 error:

            "detail": "SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''...\n)\n",

The correct behavior should be that a wrong operator is not allowed.

CommentFileSizeAuthor
#4 2900652-4.patch1.42 KBwim leers

Comments

meba created an issue. See original summary.

e0ipso’s picture

Thanks for the report. I would love to get validation on all the allowed operators by EntityQuery. However that may be a challenge since different storages (Drupal supports other than SQL) may support different operators.

Any ideas?

wim leers’s picture

Status: Active » Closed (duplicate)
Issue tags: +API-First Initiative
Related issues: +#2874601: refactor(QueryBuilder): Improve testability/maintainability

#2874601: refactor(QueryBuilder): Improve testability/maintainability fixed this! See \Drupal\jsonapi\Normalizer\EntityConditionNormalizer::validate().

wim leers’s picture

Status: Closed (duplicate) » Needs review
StatusFileSize
new1.42 KB

Actually, if we want to, we could expand the test coverage with this explicit example.

I personally don't think it's necessary, but I'll let @e0ipso decide.

dawehner’s picture

In an ideal world entity query would not allow to have this filter and throw a helpful exception.

wim leers’s picture

+1

wim leers’s picture

Title: SQL error when filtering by a wrong operator » Test coverage: non-supported operator should generate a helpful 4xx response
Category: Bug report » Task
Issue tags: +DX (Developer Experience)

The bug already was fixed by #2874601: refactor(QueryBuilder): Improve testability/maintainability, this is just adding test coverage. IMHO #4 is ready.

  • gabesullice committed 7cfcb83 on 8.x-1.x authored by Wim Leers
    Issue #2900652 by Wim Leers, meba: Test coverage: non-supported operator...
gabesullice’s picture

Status: Needs review » Fixed

Agreed.

Thanks @Wim Leers and thanks for the report @meba!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.