You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I set up laravel-search-string, and then use a search string e.g. "sort:invalid-field" then a database exception is raised (Undefined column: 7 ERROR: column table.invalid-field).
As search string is exposed to the user, I don't think invalid input should result in an exception, but should fail gracefully. If the native exception can't be caught and handled, then perhaps a the "sortable" columns should be set in the model config?
Note that my fail strategy is set to "all-results".
The text was updated successfully, but these errors were encountered:
So I can catch the exception and do something like the following. However, I still feel that the default behaviour should be to catch and silently fail in this scenario (or at least according to the fail strategy defined in the config).
An enhancement might be to observe the config (i.e. catch the exception when asked) but raise a flag on the collection in some way so that it can be presented (i.e. allow simplification of the code above).
That's a good point and I think we could improve that by adding a check prior to building the query but it would also mean that users have to whitelist the columns that can be sorted through. Which, to be honest, is probably not a bad thing since we might not want users to sort through columns that are not indexed for example.
When I set up laravel-search-string, and then use a search string e.g. "sort:invalid-field" then a database exception is raised (Undefined column: 7 ERROR: column table.invalid-field).
I don't think I've done anything wrong (but it's obviously possible).
As search string is exposed to the user, I don't think invalid input should result in an exception, but should fail gracefully. If the native exception can't be caught and handled, then perhaps a the "sortable" columns should be set in the model config?
Note that my fail strategy is set to "all-results".
The text was updated successfully, but these errors were encountered: