Skip to content

Commit 68cadc5

Browse files
authored
Merge pull request #832 from jeffgbutler/sort-deprecations
Remove Deprecated sortSpecification Methods
2 parents 8263897 + f920911 commit 68cadc5

File tree

4 files changed

+9
-208
lines changed

4 files changed

+9
-208
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ worked to make these changes as minimal as possible.
1212

1313
**Potentially Breaking Changes:**
1414

15+
- If you have created any custom implementations of `SortSpecification`, you will need to update those
16+
implementations due to a new rendering strategy for ORDER BY phrases. The old methods `isDescending` and `orderByName`
17+
are removed in favor of a new method `renderForOrderBy`
1518
- If you have implemented any custom functions, you will likely need to make changes. The supplied base classes now
1619
hold an instance of `BasicColumn` rather than `BindableColumn`. This change was made to make the functions more
1720
useful in variety of circumstances. If you follow the patterns shown on the

src/main/java/org/mybatis/dynamic/sql/SortSpecification.java

+6-33
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
*/
1616
package org.mybatis.dynamic.sql;
1717

18-
import org.mybatis.dynamic.sql.exception.DynamicSqlException;
1918
import org.mybatis.dynamic.sql.render.RenderingContext;
2019
import org.mybatis.dynamic.sql.util.FragmentAndParameters;
21-
import org.mybatis.dynamic.sql.util.Messages;
2220

2321
/**
2422
* Defines attributes of columns that are necessary for rendering an order by expression.
@@ -35,37 +33,12 @@ public interface SortSpecification {
3533
SortSpecification descending();
3634

3735
/**
38-
* Return the phrase that should be written into a rendered order by clause. This should
39-
* NOT include the "DESC" word for descending sort specifications.
36+
* Return a fragment rendered for use in an ORDER BY clause. The fragment should include "DESC" if a
37+
* descending order is desired.
4038
*
41-
* @return the order by phrase
42-
* @deprecated Please replace this method by overriding the more general "renderForOrderBy" method. Target for
43-
* removal in release 2.1
39+
* @param renderingContext the current rendering context
40+
* @return a rendered fragment and parameters if applicable
41+
* @since 2.0.0
4442
*/
45-
@Deprecated(since = "2.0", forRemoval = true)
46-
default String orderByName() {
47-
throw new DynamicSqlException(Messages.getString("ERROR.44")); //$NON-NLS-1$
48-
}
49-
50-
/**
51-
* Return true if the sort order is descending.
52-
*
53-
* @return true if the SortSpecification should render as descending
54-
* @deprecated Please replace this method by overriding the more general "renderForOrderBy" method. Target for
55-
* removal in release 2.1
56-
*/
57-
@Deprecated(since = "2.0", forRemoval = true)
58-
default boolean isDescending() {
59-
throw new DynamicSqlException(Messages.getString("ERROR.44")); //$NON-NLS-1$
60-
}
61-
62-
// the default implementation ensures compatibility with prior releases. When the
63-
// deprecated methods are removed, this function can become purely abstract.
64-
default FragmentAndParameters renderForOrderBy(RenderingContext renderingContext) {
65-
String phrase = orderByName();
66-
if (isDescending()) {
67-
phrase = phrase + " DESC"; //$NON-NLS-1$
68-
}
69-
return FragmentAndParameters.fromFragment(phrase);
70-
}
43+
FragmentAndParameters renderForOrderBy(RenderingContext renderingContext);
7144
}

src/main/resources/org/mybatis/dynamic/sql/util/messages.properties

-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,4 @@ ERROR.40=Case expressions must have at least one "when" clause
6060
ERROR.41=You cannot call "then" in a Kotlin case expression more than once
6161
ERROR.42=You cannot call `else` in a Kotlin case expression more than once
6262
ERROR.43=A Kotlin cast expression must have one, and only one, `as` element
63-
ERROR.44=You must either implement the "renderForOrderBy" method or both "orderByName" and "isDescending" methods in a \
64-
sort specification
6563
INTERNAL.ERROR=Internal Error {0}

src/test/java/org/mybatis/dynamic/sql/DeprecatedSortMethodsTest.java

-173
This file was deleted.

0 commit comments

Comments
 (0)