Skip to content

Commit b6832c1

Browse files
committed
Merge branch 'master' into window-functions
2 parents e7dc053 + a7cfd83 commit b6832c1

File tree

14 files changed

+72
-127
lines changed

14 files changed

+72
-127
lines changed

pom.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<java.release.version>17</java.release.version>
6161
<java.test.version>17</java.test.version>
6262
<java.test.release.version>17</java.test.release.version>
63-
<junit.jupiter.version>6.0.0</junit.jupiter.version>
63+
<junit.jupiter.version>6.0.1</junit.jupiter.version>
6464
<spring.batch.version>5.2.4</spring.batch.version>
6565

6666
<checkstyle.config>checkstyle-override.xml</checkstyle.config>
@@ -69,7 +69,7 @@
6969

7070
<module.name>org.mybatis.dynamic.sql</module.name>
7171

72-
<kotlin.version>2.1.21</kotlin.version>
72+
<kotlin.version>2.2.21</kotlin.version>
7373
<kotlin.compiler.jvmTarget>17</kotlin.compiler.jvmTarget>
7474
<kotlin.compiler.languageVersion>2.0</kotlin.compiler.languageVersion>
7575
<kotlin.compiler.apiVersion>2.0</kotlin.compiler.apiVersion>
@@ -80,7 +80,7 @@
8080
<sonar.host.url>http://localhost:9000</sonar.host.url>
8181

8282
<kotlin.code.style>official</kotlin.code.style>
83-
<test.containers.version>1.21.3</test.containers.version>
83+
<test.containers.version>2.0.1</test.containers.version>
8484
<osgi.export>org.mybatis.dynamic.sql.*;version=${project.version};-noimport:=true</osgi.export>
8585

8686
<!-- Reproducible Builds -->
@@ -95,7 +95,7 @@
9595
</dependency>
9696
<dependency>
9797
<groupId>org.jetbrains.kotlin</groupId>
98-
<artifactId>kotlin-stdlib-jdk8</artifactId>
98+
<artifactId>kotlin-stdlib</artifactId>
9999
<version>${kotlin.version}</version>
100100
<scope>provided</scope>
101101
<optional>true</optional>
@@ -177,13 +177,13 @@
177177
</dependency>
178178
<dependency>
179179
<groupId>org.testcontainers</groupId>
180-
<artifactId>junit-jupiter</artifactId>
180+
<artifactId>testcontainers-junit-jupiter</artifactId>
181181
<version>${test.containers.version}</version>
182182
<scope>test</scope>
183183
</dependency>
184184
<dependency>
185185
<groupId>org.testcontainers</groupId>
186-
<artifactId>postgresql</artifactId>
186+
<artifactId>testcontainers-postgresql</artifactId>
187187
<version>${test.containers.version}</version>
188188
<scope>test</scope>
189189
</dependency>
@@ -195,7 +195,7 @@
195195
</dependency>
196196
<dependency>
197197
<groupId>org.testcontainers</groupId>
198-
<artifactId>mariadb</artifactId>
198+
<artifactId>testcontainers-mariadb</artifactId>
199199
<version>${test.containers.version}</version>
200200
<scope>test</scope>
201201
</dependency>
@@ -207,14 +207,14 @@
207207
</dependency>
208208
<dependency>
209209
<groupId>org.testcontainers</groupId>
210-
<artifactId>mysql</artifactId>
210+
<artifactId>testcontainers-mysql</artifactId>
211211
<version>${test.containers.version}</version>
212212
<scope>test</scope>
213213
</dependency>
214214
<dependency>
215215
<groupId>com.mysql</groupId>
216216
<artifactId>mysql-connector-j</artifactId>
217-
<version>9.4.0</version>
217+
<version>9.5.0</version>
218218
<scope>test</scope>
219219
</dependency>
220220
</dependencies>

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

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* the {@link SqlTable} the column is a part of.
3434
*
3535
* <p>The class can be extended if you wish to associate additional attributes with a column for your
36-
* own purposes. Extending the class is a bit more challenging than you might expect because you will need to
36+
* own purposes. Extending the class is a bit more challenging than you might expect because you may need to
3737
* handle the covariant types for many methods in {@code SqlColumn}. Additionally, many methods in {@code SqlColumn}
3838
* create new instances of the class in keeping with the library's primary strategy of immutability. You will also
3939
* need to ensure that these methods create instances of your extended class, rather than the base {@code SqlColumn}
@@ -44,16 +44,18 @@
4444
* <li>Create a class that extends {@link SqlColumn}</li>
4545
* <li>In your extended class, create a static builder class that extends {@link SqlColumn.AbstractBuilder}</li>
4646
* <li>Add your desired attributes to the class and the builder</li>
47-
* <li>In your extended class, override the {@link SqlColumn#copyBuilder()} method and return a new instance of
48-
* your builder with all attributes set. You should call the
47+
* <li>You MUST override the {@link SqlColumn#copyBuilder()} method and return a new instance of
48+
* your builder with all attributes set. In the overridden method you should call the superclass
4949
* {@link SqlColumn#populateBaseBuilder(AbstractBuilder)} method
50-
* to set the attributes from {@code SqlColumn}, then populate your extended attributes.
50+
* to set the attributes from the base {@code SqlColumn}, then populate your extended attributes. During normal
51+
* usage, the library may create additional instances of your class. If you do not override the
52+
* {@link SqlColumn#copyBuilder()} method properly, then your extended attributes will be lost.
5153
* </li>
52-
* <li>You MUST override the following methods. These methods are used with regular operations in the library.
53-
* If you do not override these methods, it is likely that your extended attributes will be lost during
54-
* regular usage. For example, if you do not override the {@code as} method and a user calls the method to
55-
* apply an alias, then the base {@code SqlColumn} class would create a new instance of {@code SqlColumn}, NOT
56-
* your extended class.
54+
* <li>You MAY override the following methods. These methods are used with regular operations in the library and
55+
* create new instances of the class. However, these methods are not typically chained, so losing the specific
56+
* type may not be a problem. If you want to preserve the type, then you can override these methods
57+
* to specify the covariant return type. See below for usage of the {@link SqlColumn#cast(SqlColumn)} method
58+
* to make it easier to override these methods.
5759
* <ul>
5860
* <li>{@link SqlColumn#as(String)}</li>
5961
* <li>{@link SqlColumn#asCamelCase()}</li>
@@ -63,8 +65,10 @@
6365
* </li>
6466
* <li>You SHOULD override the following methods. These methods can be used to add additional attributes to a
6567
* column by creating a new instance with a specified attribute set. These methods are used during the
66-
* construction of columns. If you do not override these methods, and a user calls them, then a new
67-
* {@code SqlColumn} will be created that does not contain your extended attributes.
68+
* construction of columns. If you do not override these methods, and a user calls them, then the specific type
69+
* will be lost. If you want to preserve the type, then you can override these methods
70+
* to specify the covariant return type. See below for usage of the {@link SqlColumn#cast(SqlColumn)} method
71+
* to make it easier to override these methods.
6872
* <ul>
6973
* <li>{@link SqlColumn#withJavaProperty(String)}</li>
7074
* <li>{@link SqlColumn#withRenderingStrategy(RenderingStrategy)}</li>
@@ -88,7 +92,7 @@
8892
* }
8993
* </pre>
9094
*
91-
* <p>The test code for this library contains an example of a proper extension of this class.
95+
* <p>The test code for this library contains an example of a fully executed extension of this class.
9296
*
9397
* @param <T> the Java type associated with the column
9498
*/
@@ -164,7 +168,7 @@ public Optional<String> javaProperty() {
164168
*/
165169
@Override
166170
public SqlColumn<T> descending() {
167-
return cast(copyBuilder().withDescendingPhrase(" DESC").build()); //$NON-NLS-1$
171+
return copyBuilder().withDescendingPhrase(" DESC").build(); //$NON-NLS-1$
168172
}
169173

170174
/**
@@ -177,7 +181,7 @@ public SqlColumn<T> descending() {
177181
*/
178182
@Override
179183
public SqlColumn<T> as(String alias) {
180-
return cast(copyBuilder().withAlias(alias).build());
184+
return copyBuilder().withAlias(alias).build();
181185
}
182186

183187
/**
@@ -188,7 +192,7 @@ public SqlColumn<T> as(String alias) {
188192
* @return a new column that will be rendered with the specified table qualifier
189193
*/
190194
public SqlColumn<T> qualifiedWith(String tableQualifier) {
191-
return cast(copyBuilder().withTableQualifier(tableQualifier).build());
195+
return copyBuilder().withTableQualifier(tableQualifier).build();
192196
}
193197

194198
/**
@@ -203,9 +207,9 @@ public SqlColumn<T> qualifiedWith(String tableQualifier) {
203207
* @return a new column aliased with a camel case version of the column name
204208
*/
205209
public SqlColumn<T> asCamelCase() {
206-
return cast(copyBuilder()
210+
return copyBuilder()
207211
.withAlias("\"" + StringUtilities.toCamelCase(name) + "\"") //$NON-NLS-1$ //$NON-NLS-2$
208-
.build());
212+
.build();
209213
}
210214

211215
@Override
@@ -318,6 +322,14 @@ public <S> SqlColumn<S> withJavaProperty(String javaProperty) {
318322
return cast(copyBuilder().withJavaProperty(javaProperty).build());
319323
}
320324

325+
/**
326+
* Create a new Builder, then populate all attributes in the builder with current values.
327+
*
328+
* <p>This method is used to create copies of the class during normal operations (e.g. when calling the
329+
* {@link SqlColumn#as(String)} method). Any subclass of {@code SqlColumn} MUST override this method.
330+
*
331+
* @return a new Builder instance with all current values populated
332+
*/
321333
protected AbstractBuilder<T, ?, ?> copyBuilder() {
322334
return populateBaseBuilder(new Builder<>());
323335
}

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/GroupingCriteriaCollector.kt

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,6 @@ open class GroupingCriteriaCollector : SubCriteriaCollector() {
317317

318318
fun <T : Any> BindableColumn<T>.isIn(vararg values: T) = isIn(values.asList())
319319

320-
@JvmName("isInArray")
321-
infix fun <T : Any> BindableColumn<T>.isIn(values: Array<out T>) =
322-
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isIn(values))
323-
324320
infix fun <T : Any> BindableColumn<T>.isIn(values: Collection<T>) =
325321
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isIn(values))
326322

@@ -329,19 +325,11 @@ open class GroupingCriteriaCollector : SubCriteriaCollector() {
329325

330326
fun <T : Any> BindableColumn<T>.isInWhenPresent(vararg values: T?) = isInWhenPresent(values.asList())
331327

332-
@JvmName("isInArrayWhenPresent")
333-
infix fun <T : Any> BindableColumn<T>.isInWhenPresent(values: Array<out T?>?) =
334-
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isInWhenPresent(values))
335-
336328
infix fun <T : Any> BindableColumn<T>.isInWhenPresent(values: Collection<T?>?) =
337329
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isInWhenPresent(values))
338330

339331
fun <T : Any> BindableColumn<T>.isNotIn(vararg values: T) = isNotIn(values.asList())
340332

341-
@JvmName("isNotInArray")
342-
infix fun <T : Any> BindableColumn<T>.isNotIn(values: Array<out T>) =
343-
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isNotIn(values))
344-
345333
infix fun <T : Any> BindableColumn<T>.isNotIn(values: Collection<T>) =
346334
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isNotIn(values))
347335

@@ -350,10 +338,6 @@ open class GroupingCriteriaCollector : SubCriteriaCollector() {
350338

351339
fun <T : Any> BindableColumn<T>.isNotInWhenPresent(vararg values: T?) = isNotInWhenPresent(values.asList())
352340

353-
@JvmName("isNotInArrayWhenPresent")
354-
infix fun <T : Any> BindableColumn<T>.isNotInWhenPresent(values: Array<out T?>?) =
355-
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isNotInWhenPresent(values))
356-
357341
infix fun <T : Any> BindableColumn<T>.isNotInWhenPresent(values: Collection<T?>?) =
358342
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isNotInWhenPresent(values))
359343

@@ -410,40 +394,24 @@ open class GroupingCriteriaCollector : SubCriteriaCollector() {
410394

411395
fun BindableColumn<String>.isInCaseInsensitive(vararg values: String) = isInCaseInsensitive(values.asList())
412396

413-
@JvmName("isInArrayCaseInsensitive")
414-
infix fun BindableColumn<String>.isInCaseInsensitive(values: Array<out String>) =
415-
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isInCaseInsensitive(values))
416-
417397
infix fun BindableColumn<String>.isInCaseInsensitive(values: Collection<String>) =
418398
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isInCaseInsensitive(values))
419399

420400
fun BindableColumn<String>.isInCaseInsensitiveWhenPresent(vararg values: String?) =
421401
isInCaseInsensitiveWhenPresent(values.asList())
422402

423-
@JvmName("isInArrayCaseInsensitiveWhenPresent")
424-
infix fun BindableColumn<String>.isInCaseInsensitiveWhenPresent(values: Array<out String?>?) =
425-
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isInCaseInsensitiveWhenPresent(values))
426-
427403
infix fun BindableColumn<String>.isInCaseInsensitiveWhenPresent(values: Collection<String?>?) =
428404
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isInCaseInsensitiveWhenPresent(values))
429405

430406
fun BindableColumn<String>.isNotInCaseInsensitive(vararg values: String) =
431407
isNotInCaseInsensitive(values.asList())
432408

433-
@JvmName("isNotInArrayCaseInsensitive")
434-
infix fun BindableColumn<String>.isNotInCaseInsensitive(values: Array<out String>) =
435-
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isNotInCaseInsensitive(values))
436-
437409
infix fun BindableColumn<String>.isNotInCaseInsensitive(values: Collection<String>) =
438410
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isNotInCaseInsensitive(values))
439411

440412
fun BindableColumn<String>.isNotInCaseInsensitiveWhenPresent(vararg values: String?) =
441413
isNotInCaseInsensitiveWhenPresent(values.asList())
442414

443-
@JvmName("isNotInArrayCaseInsensitiveWhenPresent")
444-
infix fun BindableColumn<String>.isNotInCaseInsensitiveWhenPresent(values: Array<out String?>?) =
445-
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isNotInCaseInsensitiveWhenPresent(values))
446-
447415
infix fun BindableColumn<String>.isNotInCaseInsensitiveWhenPresent(values: Collection<String?>?) =
448416
invoke(org.mybatis.dynamic.sql.util.kotlin.elements.isNotInCaseInsensitiveWhenPresent(values))
449417

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/elements/SqlElements.kt

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -286,36 +286,24 @@ fun <T : Any> isLessThanOrEqualToWhenPresent(value: T?): IsLessThanOrEqualToWhen
286286

287287
fun <T : Any> isIn(vararg values: T): IsIn<T> = isIn(values.asList())
288288

289-
@JvmName("isInArray")
290-
fun <T : Any> isIn(values: Array<out T>): IsIn<T> = SqlBuilder.isIn(values.asList())
291-
292289
fun <T : Any> isIn(values: Collection<T>): IsIn<T> = SqlBuilder.isIn(values)
293290

294291
fun <T : Any> isIn(subQuery: KotlinSubQueryBuilder.() -> Unit): IsInWithSubselect<T> =
295292
SqlBuilder.isIn(KotlinSubQueryBuilder().apply(subQuery))
296293

297294
fun <T : Any> isInWhenPresent(vararg values: T?): IsInWhenPresent<T> = isInWhenPresent(values.asList())
298295

299-
@JvmName("isInArrayWhenPresent")
300-
fun <T : Any> isInWhenPresent(values: Array<out T?>?): IsInWhenPresent<T> = SqlBuilder.isInWhenPresent(values?.asList())
301-
302296
fun <T : Any> isInWhenPresent(values: Collection<T?>?): IsInWhenPresent<T> = SqlBuilder.isInWhenPresent(values)
303297

304298
fun <T : Any> isNotIn(vararg values: T): IsNotIn<T> = isNotIn(values.asList())
305299

306-
@JvmName("isNotInArray")
307-
fun <T : Any> isNotIn(values: Array<out T>): IsNotIn<T> = SqlBuilder.isNotIn(values.asList())
308-
309300
fun <T : Any> isNotIn(values: Collection<T>): IsNotIn<T> = SqlBuilder.isNotIn(values)
310301

311302
fun <T : Any> isNotIn(subQuery: KotlinSubQueryBuilder.() -> Unit): IsNotInWithSubselect<T> =
312303
SqlBuilder.isNotIn(KotlinSubQueryBuilder().apply(subQuery))
313304

314305
fun <T : Any> isNotInWhenPresent(vararg values: T?): IsNotInWhenPresent<T> = isNotInWhenPresent(values.asList())
315306

316-
@JvmName("isNotInArrayWhenPresent")
317-
fun <T : Any> isNotInWhenPresent(values: Array<out T?>?): IsNotInWhenPresent<T> = SqlBuilder.isNotInWhenPresent(values?.asList())
318-
319307
fun <T : Any> isNotInWhenPresent(values: Collection<T?>?): IsNotInWhenPresent<T> = SqlBuilder.isNotInWhenPresent(values)
320308

321309
fun <T : Any> isBetween(value1: T): BetweenBuilder<T> = BetweenBuilder(value1)
@@ -354,40 +342,24 @@ fun isNotLikeCaseInsensitiveWhenPresent(value: String?): IsNotLikeCaseInsensitiv
354342

355343
fun isInCaseInsensitive(vararg values: String): IsInCaseInsensitive<String> = isInCaseInsensitive(values.asList())
356344

357-
@JvmName("isInArrayCaseInsensitive")
358-
fun isInCaseInsensitive(values: Array<out String>): IsInCaseInsensitive<String> =
359-
SqlBuilder.isInCaseInsensitive(values.asList())
360-
361345
fun isInCaseInsensitive(values: Collection<String>): IsInCaseInsensitive<String> =
362346
SqlBuilder.isInCaseInsensitive(values)
363347

364348
fun isInCaseInsensitiveWhenPresent(vararg values: String?): IsInCaseInsensitiveWhenPresent<String> =
365349
isInCaseInsensitiveWhenPresent(values.asList())
366350

367-
@JvmName("isInArrayCaseInsensitiveWhenPresent")
368-
fun isInCaseInsensitiveWhenPresent(values: Array<out String?>?): IsInCaseInsensitiveWhenPresent<String> =
369-
SqlBuilder.isInCaseInsensitiveWhenPresent(values?.asList())
370-
371351
fun isInCaseInsensitiveWhenPresent(values: Collection<String?>?): IsInCaseInsensitiveWhenPresent<String> =
372352
SqlBuilder.isInCaseInsensitiveWhenPresent(values)
373353

374354
fun isNotInCaseInsensitive(vararg values: String): IsNotInCaseInsensitive<String> =
375355
isNotInCaseInsensitive(values.asList())
376356

377-
@JvmName("isNotInArrayCaseInsensitive")
378-
fun isNotInCaseInsensitive(values: Array<out String>): IsNotInCaseInsensitive<String> =
379-
SqlBuilder.isNotInCaseInsensitive(values.asList())
380-
381357
fun isNotInCaseInsensitive(values: Collection<String>): IsNotInCaseInsensitive<String> =
382358
SqlBuilder.isNotInCaseInsensitive(values)
383359

384360
fun isNotInCaseInsensitiveWhenPresent(vararg values: String?): IsNotInCaseInsensitiveWhenPresent<String> =
385361
isNotInCaseInsensitiveWhenPresent(values.asList())
386362

387-
@JvmName("isNotInArrayCaseInsensitiveWhenPresent")
388-
fun isNotInCaseInsensitiveWhenPresent(values: Array<out String?>?): IsNotInCaseInsensitiveWhenPresent<String> =
389-
SqlBuilder.isNotInCaseInsensitiveWhenPresent(values?.asList())
390-
391363
fun isNotInCaseInsensitiveWhenPresent(values: Collection<String?>?): IsNotInCaseInsensitiveWhenPresent<String> =
392364
SqlBuilder.isNotInCaseInsensitiveWhenPresent(values)
393365

src/test/java/config/TestContainersConfiguration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@
2323
public interface TestContainersConfiguration {
2424
DockerImageName POSTGRES_LATEST = DockerImageName.parse("postgres:18.0");
2525
DockerImageName MARIADB_LATEST = DockerImageName.parse("mariadb:12.0.2");
26-
// Note - Can't go past MySQL:9.2.0 until this is released: https://github.com/testcontainers/testcontainers-java/pull/10185
27-
DockerImageName MYSQL_LATEST = DockerImageName.parse("mysql:9.2.0");
26+
DockerImageName MYSQL_LATEST = DockerImageName.parse("mysql:9.5.0");
2827
}

src/test/java/examples/custom_render/CustomRenderingTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,16 @@
5050
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
5151
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
5252
import org.mybatis.dynamic.sql.util.mybatis3.CommonSelectMapper;
53-
import org.testcontainers.containers.PostgreSQLContainer;
5453
import org.testcontainers.junit.jupiter.Container;
5554
import org.testcontainers.junit.jupiter.Testcontainers;
55+
import org.testcontainers.postgresql.PostgreSQLContainer;
5656

5757
@Testcontainers
5858
class CustomRenderingTest {
5959

60-
@SuppressWarnings("resource")
6160
@Container
62-
private static final PostgreSQLContainer<?> postgres =
63-
new PostgreSQLContainer<>(TestContainersConfiguration.POSTGRES_LATEST)
61+
private static final PostgreSQLContainer postgres =
62+
new PostgreSQLContainer(TestContainersConfiguration.POSTGRES_LATEST)
6463
.withInitScript("examples/custom_render/dbInit.sql");
6564

6665
private SqlSessionFactory sqlSessionFactory;

0 commit comments

Comments
 (0)