Document _sortBy sorting support - #94
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 128d592925
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "Some requests can be filtered by adding query params of fieldname=value. Where only matching items will be returned.")); | ||
| output.append( | ||
| paragraph( | ||
| "Filter conditions can use <i>field=value</i> for equals, <i>field!=value</i> or <i>field!value</i> for not equals, <i>field<value</i>, <i>field>value</i>, <i>field<=value</i>, and <i>field>=value</i> for comparisons, <i>field~=regex</i> for regular expression matches, and <i>field*=wildcard</i> for wildcard matches where <i>*</i> matches many characters and <i>?</i> matches one character. Multiple query params are combined as AND conditions.")); |
There was a problem hiding this comment.
Correct the claim that all filter parameters are ANDed
The AND guarantee is false when a regex or wildcard filter precedes another condition. EntityListFilterParamParser.matches returns immediately from its ~= and *= cases, so a request such as ?title*=Task*&status=false accepts an item as soon as its title matches without checking status. Either continue evaluating the remaining filters in those cases or qualify the generated documentation.
Useful? React with 👍 / 👎.
| Field primaryKeyField = filterableEntity.getPrimaryKeyField(); | ||
| if (primaryKeyField != null) { | ||
| return primaryKeyField.getName(); |
There was a problem hiding this comment.
Avoid generating examples for unsortable primary keys
When the filterable entity has an AUTO_GUID primary key, this selects that field and generates an OpenAPI example such as _sortBy=+guid, but the in-memory sorter compares through ComparableFieldValue, which has no AUTO_GUID branch and therefore treats every GUID as equal. The documented example consequently leaves results unsorted in the in-memory repository while SQLite sorts them; either add GUID comparison support or choose/document only supported field types.
Useful? React with 👍 / 👎.
Summary
_sortBy.sortBy,sortby, andsort_byas ordinary filter field names again.Validation
EntityInstanceListSorterunit testsspotless:checkgit diff --check