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.
Comments
Comment #2
e0ipsoThanks 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?
Comment #3
wim leers#2874601: refactor(QueryBuilder): Improve testability/maintainability fixed this! See
\Drupal\jsonapi\Normalizer\EntityConditionNormalizer::validate().Comment #4
wim leersActually, 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.
Comment #5
dawehnerIn an ideal world entity query would not allow to have this filter and throw a helpful exception.
Comment #6
wim leers+1
Comment #7
wim leersThe bug already was fixed by #2874601: refactor(QueryBuilder): Improve testability/maintainability, this is just adding test coverage. IMHO #4 is ready.
Comment #9
gabesulliceAgreed.
Thanks @Wim Leers and thanks for the report @meba!