Skip to content

Commit 35ea978

Browse files
committed
Merge branch 'refs/heads/master' into java-11-update
# Conflicts: # pom.xml
2 parents c3ec124 + 3fb12f7 commit 35ea978

File tree

82 files changed

+2043
-1205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2043
-1205
lines changed

.github/workflows/codeql.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ jobs:
5050
- name: Checkout repository
5151
uses: actions/checkout@v4
5252

53-
# Initializes the CodeQL tools for scanning.
53+
- name: Setup Java
54+
uses: actions/setup-java@v4
55+
with:
56+
java-version: 17
57+
distribution: 'temurin'
58+
59+
# Initializes the CodeQL tools for scanning.
5460
- name: Initialize CodeQL
5561
uses: github/codeql-action/init@v3
5662
with:

.github/workflows/site.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
2626
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2727
- name: Deploy Site to gh-pages
28-
uses: JamesIves/[email protected].0
28+
uses: JamesIves/[email protected].1
2929
with:
3030
ssh-key: true
3131
branch: gh-pages

.mvn/wrapper/maven-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
wrapperVersion=3.3.1
18-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
18+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip
1919
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.1/maven-wrapper-3.3.1.jar

CHANGELOG.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,21 @@
22

33
This log will detail notable changes to MyBatis Dynamic SQL. Full details are available on the GitHub milestone pages.
44

5-
## Release 1.5.2 - Unreleased
5+
## Release 1.5.2 - June 3, 2024
66

7-
This is a small maintenance release with improvements to the Kotlin DSL for CASE expressions.
7+
This is a small maintenance release with the following changes:
8+
9+
1. Improvements to the Kotlin DSL for CASE expressions (infix methods for "else" and "then"). See this PR for
10+
details: ([#785](https://github.com/mybatis/mybatis-dynamic-sql/pull/785))
11+
2. **Potentially Breaking Change**: the "in" conditions ("isIn", "isNotIn", "isInCaseInsensitive",
12+
"isNotInCaseInsensitive") will now render if the input list of values is empty. This will lead
13+
to a runtime exception. This change was made out of an abundance of caution and is the safest choice.
14+
If you wish to allow "in" conditions to be removed from where clauses when the list is empty,
15+
then use the "when present" versions of those conditions. If you are unsure how this works, please
16+
read the documentation here: https://mybatis.org/mybatis-dynamic-sql/docs/conditions.html#optionality-with-the-%E2%80%9Cin%E2%80%9D-conditions
17+
For background on the reason for the change, see the discussion here: https://github.com/mybatis/mybatis-dynamic-sql/issues/788
18+
19+
GitHub milestone: [https://github.com/mybatis/mybatis-dynamic-sql/milestone/14?closed=1](https://github.com/mybatis/mybatis-dynamic-sql/milestone/14?closed=1)
820

921
**Important:** This is the last release that will be compatible with Java 8.
1022

@@ -30,8 +42,8 @@ We've tested this extensively and the code is, of course, 100% covered by test c
3042
covered every scenario. Please let us know if you find issues.
3143

3244
Full documentation is available here:
33-
- [Java Case Expression DSL Documentation](caseExpressions.md)
34-
- [Kotlin Case Expression DSL Documentation](kotlinCaseExpressions.md)
45+
- [Java Case Expression DSL Documentation](https://mybatis.org/mybatis-dynamic-sql/docs/caseExpressions.html)
46+
- [Kotlin Case Expression DSL Documentation](https://mybatis.org/mybatis-dynamic-sql/docs/kotlinCaseExpressions.html)
3547

3648
The pull request for this change is ([#761](https://github.com/mybatis/mybatis-dynamic-sql/pull/761))
3749

pom.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>org.mybatis</groupId>
2323
<artifactId>mybatis-parent</artifactId>
24-
<version>43</version>
24+
<version>44</version>
2525
</parent>
2626

2727
<groupId>org.mybatis.dynamic-sql</groupId>
@@ -59,27 +59,27 @@
5959
<java.version>17</java.version>
6060
<java.release.version>11</java.release.version>
6161
<junit.jupiter.version>5.10.2</junit.jupiter.version>
62-
<spring.batch.version>5.1.1</spring.batch.version>
62+
<spring.batch.version>5.1.2</spring.batch.version>
6363

6464
<checkstyle.config>checkstyle-override.xml</checkstyle.config>
6565

6666
<clirr.comparisonVersion>1.5.0</clirr.comparisonVersion>
6767

6868
<module.name>org.mybatis.dynamic.sql</module.name>
6969

70-
<kotlin.version>1.9.23</kotlin.version>
70+
<kotlin.version>2.0.0</kotlin.version>
7171
<kotlin.compiler.jvmTarget>11</kotlin.compiler.jvmTarget>
7272
<kotlin.compiler.apiVersion>1.6</kotlin.compiler.apiVersion>
7373

7474
<sonar.sources>pom.xml,src/main/java,src/main/kotlin</sonar.sources>
7575
<sonar.tests>src/test/java,src/test/kotlin</sonar.tests>
7676

7777
<kotlin.code.style>official</kotlin.code.style>
78-
<test.containers.version>1.19.7</test.containers.version>
78+
<test.containers.version>1.19.8</test.containers.version>
7979
<osgi.export>org.mybatis.dynamic.sql.*;version=${project.version};-noimport:=true</osgi.export>
8080

8181
<!-- Reproducible Builds -->
82-
<project.build.outputTimestamp>1714504234</project.build.outputTimestamp>
82+
<project.build.outputTimestamp>1717449335</project.build.outputTimestamp>
8383
</properties>
8484

8585
<dependencies>
@@ -93,7 +93,7 @@
9393
<dependency>
9494
<groupId>org.springframework</groupId>
9595
<artifactId>spring-jdbc</artifactId>
96-
<version>6.1.6</version>
96+
<version>6.1.8</version>
9797
<scope>provided</scope>
9898
<optional>true</optional>
9999
</dependency>
@@ -126,7 +126,7 @@
126126
<dependency>
127127
<groupId>org.assertj</groupId>
128128
<artifactId>assertj-core</artifactId>
129-
<version>3.25.3</version>
129+
<version>3.26.0</version>
130130
<scope>test</scope>
131131
</dependency>
132132
<dependency>
@@ -138,7 +138,7 @@
138138
<dependency>
139139
<groupId>org.hsqldb</groupId>
140140
<artifactId>hsqldb</artifactId>
141-
<version>2.7.2</version>
141+
<version>2.7.3</version>
142142
<scope>test</scope>
143143
</dependency>
144144
<dependency>
@@ -200,7 +200,7 @@
200200
<dependency>
201201
<groupId>org.mariadb.jdbc</groupId>
202202
<artifactId>mariadb-java-client</artifactId>
203-
<version>3.3.3</version>
203+
<version>3.4.0</version>
204204
<scope>test</scope>
205205
</dependency>
206206
</dependencies>
@@ -321,7 +321,7 @@
321321
<plugin>
322322
<groupId>org.codehaus.mojo</groupId>
323323
<artifactId>build-helper-maven-plugin</artifactId>
324-
<version>3.5.0</version>
324+
<version>3.6.0</version>
325325
<executions>
326326
<execution>
327327
<goals>

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

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import java.util.stream.Collectors;
2424
import java.util.stream.Stream;
2525

26-
import org.mybatis.dynamic.sql.render.RenderingContext;
27-
2826
public abstract class AbstractListValueCondition<T> implements VisitableCondition<T> {
2927
protected final Collection<T> values;
3028

@@ -41,15 +39,6 @@ public boolean isEmpty() {
4139
return values.isEmpty();
4240
}
4341

44-
@Override
45-
public boolean shouldRender(RenderingContext renderingContext) {
46-
if (isEmpty()) {
47-
return renderingContext.isEmptyListConditionRenderingAllowed();
48-
} else {
49-
return true;
50-
}
51-
}
52-
5342
@Override
5443
public <R> R accept(ConditionVisitor<T, R> visitor) {
5544
return visitor.visit(this);
@@ -85,14 +74,12 @@ protected <R, S extends AbstractListValueCondition<R>> S mapSupport(Function<? s
8574
}
8675

8776
/**
88-
* If renderable, apply the predicate to each value in the list and return a new condition with the filtered values.
89-
* Else returns a condition that will not render (this). If all values are filtered out of the value
90-
* list, then the condition will not render.
77+
* If not empty, apply the predicate to each value in the list and return a new condition with the filtered values.
78+
* Else returns an empty condition (this).
9179
*
92-
* @param predicate
93-
* predicate applied to the values, if renderable
80+
* @param predicate predicate applied to the values, if not empty
9481
*
95-
* @return a new condition with filtered values if renderable, otherwise a condition that will not render.
82+
* @return a new condition with filtered values if renderable, otherwise an empty condition
9683
*/
9784
public abstract AbstractListValueCondition<T> filter(Predicate<? super T> predicate);
9885

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* Existing converters may be reused if they are marked with this additional interface.
3333
*
3434
* <p>The converter is only used for parameters in a parameter map. It is not used for result set processing.
35-
* It is also not used for insert statements that are based on an external record class. The converter will be called
35+
* It is also not used for insert statements that are based on an external row class. The converter will be called
3636
* in the following circumstances:
3737
*
3838
* <ul>

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

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
import org.mybatis.dynamic.sql.where.condition.IsGreaterThanWithSubselect;
7777
import org.mybatis.dynamic.sql.where.condition.IsIn;
7878
import org.mybatis.dynamic.sql.where.condition.IsInCaseInsensitive;
79+
import org.mybatis.dynamic.sql.where.condition.IsInCaseInsensitiveWhenPresent;
80+
import org.mybatis.dynamic.sql.where.condition.IsInWhenPresent;
7981
import org.mybatis.dynamic.sql.where.condition.IsInWithSubselect;
8082
import org.mybatis.dynamic.sql.where.condition.IsLessThan;
8183
import org.mybatis.dynamic.sql.where.condition.IsLessThanColumn;
@@ -91,6 +93,8 @@
9193
import org.mybatis.dynamic.sql.where.condition.IsNotEqualToWithSubselect;
9294
import org.mybatis.dynamic.sql.where.condition.IsNotIn;
9395
import org.mybatis.dynamic.sql.where.condition.IsNotInCaseInsensitive;
96+
import org.mybatis.dynamic.sql.where.condition.IsNotInCaseInsensitiveWhenPresent;
97+
import org.mybatis.dynamic.sql.where.condition.IsNotInWhenPresent;
9498
import org.mybatis.dynamic.sql.where.condition.IsNotInWithSubselect;
9599
import org.mybatis.dynamic.sql.where.condition.IsNotLike;
96100
import org.mybatis.dynamic.sql.where.condition.IsNotLikeCaseInsensitive;
@@ -764,12 +768,12 @@ static <T> IsInWithSubselect<T> isIn(Buildable<SelectModel> selectModelBuilder)
764768
}
765769

766770
@SafeVarargs
767-
static <T> IsIn<T> isInWhenPresent(T... values) {
768-
return IsIn.of(values).filter(Objects::nonNull);
771+
static <T> IsInWhenPresent<T> isInWhenPresent(T... values) {
772+
return IsInWhenPresent.of(values);
769773
}
770774

771-
static <T> IsIn<T> isInWhenPresent(Collection<T> values) {
772-
return values == null ? IsIn.empty() : IsIn.of(values).filter(Objects::nonNull);
775+
static <T> IsInWhenPresent<T> isInWhenPresent(Collection<T> values) {
776+
return values == null ? IsInWhenPresent.empty() : IsInWhenPresent.of(values);
773777
}
774778

775779
@SafeVarargs
@@ -786,12 +790,12 @@ static <T> IsNotInWithSubselect<T> isNotIn(Buildable<SelectModel> selectModelBui
786790
}
787791

788792
@SafeVarargs
789-
static <T> IsNotIn<T> isNotInWhenPresent(T... values) {
790-
return IsNotIn.of(values).filter(Objects::nonNull);
793+
static <T> IsNotInWhenPresent<T> isNotInWhenPresent(T... values) {
794+
return IsNotInWhenPresent.of(values);
791795
}
792796

793-
static <T> IsNotIn<T> isNotInWhenPresent(Collection<T> values) {
794-
return values == null ? IsNotIn.empty() : IsNotIn.of(values).filter(Objects::nonNull);
797+
static <T> IsNotInWhenPresent<T> isNotInWhenPresent(Collection<T> values) {
798+
return values == null ? IsNotInWhenPresent.empty() : IsNotInWhenPresent.of(values);
795799
}
796800

797801
static <T> IsBetween.Builder<T> isBetween(T value1) {
@@ -909,12 +913,12 @@ static IsInCaseInsensitive isInCaseInsensitive(Collection<String> values) {
909913
return IsInCaseInsensitive.of(values);
910914
}
911915

912-
static IsInCaseInsensitive isInCaseInsensitiveWhenPresent(String... values) {
913-
return IsInCaseInsensitive.of(values).filter(Objects::nonNull);
916+
static IsInCaseInsensitiveWhenPresent isInCaseInsensitiveWhenPresent(String... values) {
917+
return IsInCaseInsensitiveWhenPresent.of(values);
914918
}
915919

916-
static IsInCaseInsensitive isInCaseInsensitiveWhenPresent(Collection<String> values) {
917-
return values == null ? IsInCaseInsensitive.empty() : IsInCaseInsensitive.of(values).filter(Objects::nonNull);
920+
static IsInCaseInsensitiveWhenPresent isInCaseInsensitiveWhenPresent(Collection<String> values) {
921+
return values == null ? IsInCaseInsensitiveWhenPresent.empty() : IsInCaseInsensitiveWhenPresent.of(values);
918922
}
919923

920924
static IsNotInCaseInsensitive isNotInCaseInsensitive(String... values) {
@@ -925,13 +929,13 @@ static IsNotInCaseInsensitive isNotInCaseInsensitive(Collection<String> values)
925929
return IsNotInCaseInsensitive.of(values);
926930
}
927931

928-
static IsNotInCaseInsensitive isNotInCaseInsensitiveWhenPresent(String... values) {
929-
return IsNotInCaseInsensitive.of(values).filter(Objects::nonNull);
932+
static IsNotInCaseInsensitiveWhenPresent isNotInCaseInsensitiveWhenPresent(String... values) {
933+
return IsNotInCaseInsensitiveWhenPresent.of(values);
930934
}
931935

932-
static IsNotInCaseInsensitive isNotInCaseInsensitiveWhenPresent(Collection<String> values) {
933-
return values == null ? IsNotInCaseInsensitive.empty() :
934-
IsNotInCaseInsensitive.of(values).filter(Objects::nonNull);
936+
static IsNotInCaseInsensitiveWhenPresent isNotInCaseInsensitiveWhenPresent(Collection<String> values) {
937+
return values == null ? IsNotInCaseInsensitiveWhenPresent.empty() :
938+
IsNotInCaseInsensitiveWhenPresent.of(values);
935939
}
936940

937941
// order by support

src/main/java/org/mybatis/dynamic/sql/configuration/GlobalConfiguration.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public class GlobalConfiguration {
2626
public static final String CONFIGURATION_FILE_PROPERTY = "mybatis-dynamic-sql.configurationFile"; //$NON-NLS-1$
2727
private static final String DEFAULT_PROPERTY_FILE = "mybatis-dynamic-sql.properties"; //$NON-NLS-1$
2828
private boolean isNonRenderingWhereClauseAllowed = false;
29-
private boolean isEmptyListConditionRenderingAllowed = false;
3029
private final Properties properties = new Properties();
3130

3231
public GlobalConfiguration() {
@@ -66,16 +65,9 @@ void loadProperties(InputStream inputStream, String propertyFile) {
6665
private void initializeKnownProperties() {
6766
String value = properties.getProperty("nonRenderingWhereClauseAllowed", "false"); //$NON-NLS-1$ //$NON-NLS-2$
6867
isNonRenderingWhereClauseAllowed = Boolean.parseBoolean(value);
69-
70-
value = properties.getProperty("emptyListConditionRenderingAllowed", "false"); //$NON-NLS-1$ //$NON-NLS-2$
71-
isEmptyListConditionRenderingAllowed = Boolean.parseBoolean(value);
7268
}
7369

7470
public boolean isIsNonRenderingWhereClauseAllowed() {
7571
return isNonRenderingWhereClauseAllowed;
7672
}
77-
78-
public boolean isEmptyListConditionRenderingAllowed() {
79-
return isEmptyListConditionRenderingAllowed;
80-
}
8173
}

src/main/java/org/mybatis/dynamic/sql/configuration/StatementConfiguration.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@
2525
* Configurable behaviors are detailed below:
2626
*
2727
* <dl>
28-
* <dt>emptyListConditionRenderingAllowed</dt>
29-
* <dd>If false (default), the framework will not render list conditions that are empty in a where clause.
30-
* This is beneficial in that it will not allow the library to generate invalid SQL, but it has a
31-
* potentially dangerous side effect where a statement could be generated that impacts more rows
32-
* then expected. If true, an empty list will be rendered as "in ()", "not in ()", etc. which will likely
33-
* cause an SQLException at runtime.
34-
* </dd>
3528
* <dt>nonRenderingWhereClauseAllowed</dt>
3629
* <dd>If false (default), the framework will throw a {@link NonRenderingWhereClauseException}
3730
* if a where clause is specified in the statement, but it fails to render because all
@@ -51,9 +44,6 @@ public class StatementConfiguration {
5144
private boolean isNonRenderingWhereClauseAllowed =
5245
GlobalContext.getConfiguration().isIsNonRenderingWhereClauseAllowed();
5346

54-
private boolean isEmptyListConditionRenderingAllowed =
55-
GlobalContext.getConfiguration().isEmptyListConditionRenderingAllowed();
56-
5747
public boolean isNonRenderingWhereClauseAllowed() {
5848
return isNonRenderingWhereClauseAllowed;
5949
}
@@ -62,13 +52,4 @@ public StatementConfiguration setNonRenderingWhereClauseAllowed(boolean nonRende
6252
isNonRenderingWhereClauseAllowed = nonRenderingWhereClauseAllowed;
6353
return this;
6454
}
65-
66-
public boolean isEmptyListConditionRenderingAllowed() {
67-
return isEmptyListConditionRenderingAllowed;
68-
}
69-
70-
public StatementConfiguration setEmptyListConditionRenderingAllowed(boolean emptyListConditionRenderingAllowed) {
71-
isEmptyListConditionRenderingAllowed = emptyListConditionRenderingAllowed;
72-
return this;
73-
}
7455
}

0 commit comments

Comments
 (0)