Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix unclear spec doc for the OrderBy keyword #577

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions spec/src/main/asciidoc/repository.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ The parsing of query method names follows a specific format:
- The method name consists of the subject, the predicate, and optionally the order clause.
- The subject begins with the action (such as `find` or `delete`) and is optionally followed by an expression (for example, `First10`), followed by any number of other characters, followed by `By`.
- The predicate defines the query's condition or filtering criteria, where multiple conditions are delimited by `And` or `Or`. For example, `PriceLessThanAndNameLike`.
- The order clause, which is optional, begins with `OrderBy` and consists of an ordered collection of entity attributes by which to sort results, delimited by `Asc` or `Desc` to specify the sort direction of the preceding attribute.
- The order clause, which is optional, begins with `OrderBy` and is followed by one or more ordered pairings consisting of entity attribute name and direction of sorting (`Asc` or `Desc`). The direction can be omitted on the final property, in which case `Asc` is implied. Ordering of results is performed by sorting the first entity attribute according to its respective direction, where results that sort to the same position are subsequently sorted by the second entity attribute according to its respective direction, and so forth.
- The method name is formed by combining the subject, predicate, and order clause, in that order.

NOTE: This specification uses the terms subject and predicate in a way that aligns with industry terminology rather than how they are defined in English grammar.
Expand All @@ -949,6 +949,7 @@ Example query methods:
- `findByAgeGreaterThan(int age)`: Find entities where 'age' is greater than the specified value.
- `findByAuthorName(String authorName)`: Find entities by the 'authorName' property of a related entity.
- `findByCategoryNameAndPriceLessThan(String categoryName, double price)`: Find entities by 'categoryName' and 'price' properties, applying an 'And' condition.
- `findByNameLikeOrderByPriceDescIdAsc`: Find entities by matching the 'name' property against a pattern, sorting the results by 'price' in descending order, and sorting results with the same 'price' by the 'id' in ascending order.

==== BNF Grammar for Query Methods

Expand Down Expand Up @@ -1110,25 +1111,20 @@ Jakarta Data implementations must support the following list of Query by Method
|Key-value, Wide-Column

|OrderBy
|Specify a static sorting order followed by the property path and direction of ascending.
|findByNameOrderByAge
|Specify a static sorting order followed by one or more ordered pairings of a property path and direction (`Asc` or `Desc`). The direction `Asc` can be omitted from the final property listed, in which case ascending order is implied for that property.
|findByAgeOrderByHeightDescIdAsc findByAgeOrderById
|Key-value, Wide-Column

|OrderBy____Desc
|Specify a static sorting order followed by the property path and direction of descending.
|Desc
|Specify a static sorting order of descending.
|findByNameOrderByAgeDesc
|Key-value, Wide-Column

|OrderBy____Asc
|Specify a static sorting order followed by the property path and direction of ascending.
|Asc
|Specify a static sorting order of ascending.
|findByNameOrderByAgeAsc
|Key-value, Wide-Column

|OrderBy____(Asc\|Desc)*(Asc\|Desc)
|Specify several static sorting orders
|findByNameOrderByAgeAscNameDescYearAsc
|Key-value, Wide-Column

|===

[NOTE]
Expand Down