Skip to content

Commit deb1815

Browse files
authored
Merge pull request #805 from jeffgbutler/misc-updates
Misc updates
2 parents 623aa00 + ef5dd4c commit deb1815

Some content is hidden

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

45 files changed

+870
-855
lines changed

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/render/RenderingStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public String formatParameterMapKey(AtomicInteger sequence) {
7979
public abstract String getFormattedJdbcPlaceholder(String prefix, String parameterName);
8080

8181
/**
82-
* This method generates a binding for a parameter to a placeholder in a record based insert statement.
82+
* This method generates a binding for a parameter to a placeholder in a row based insert statement.
8383
*
8484
* <p>This binding is specifically for use with insert, batch insert, and multirow insert statements.
8585
* These statements bind parameters to properties of a row class. The Spring implementation changes the binding
@@ -102,7 +102,7 @@ public String getRecordBasedInsertBinding(BindableColumn<?> column, String prefi
102102
}
103103

104104
/**
105-
* This method generates a binding for a parameter to a placeholder in a record based insert statement.
105+
* This method generates a binding for a parameter to a placeholder in a row based insert statement.
106106
*
107107
* <p>This binding is specifically for use with insert, batch insert, and multirow insert statements and the
108108
* MapToRow mapping. These statements bind parameters to the row class directly.

src/main/java/org/mybatis/dynamic/sql/update/UpdateDSLCompleter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
* </pre>
6060
*
6161
* <p>You could also implement a helper method that would set fields based on values of a record. For example,
62-
* the following method would set all fields of a record based on whether or not the values are null:
62+
* the following method would set all fields of a row based on whether the values are null:
6363
*
6464
* <pre>
6565
* static UpdateDSL&lt;UpdateModel&gt; updateSelectiveColumns(PersonRecord record,

src/main/java/org/mybatis/dynamic/sql/util/mybatis3/CommonInsertMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* insert statements that do NOT expect generated keys.
3030
*
3131
* @param <T>
32-
* the type of record associated with this mapper
32+
* the type of row associated with this mapper
3333
*/
3434
public interface CommonInsertMapper<T> extends CommonGeneralInsertMapper {
3535
/**

src/site/markdown/docs/conditions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ case String values to enable case-insensitive queries. There are extension point
203203
mapping if you so desire.
204204

205205
Starting with version 1.5.2, we made a change to the rendering rules for the "in" conditions. This was done to limit the
206-
danger of conditions failing to render and thus affecting more rows than expected. For the base conditions ("isIn",
206+
danger of conditions failing to render and thus affecting more rows than expected. For the base conditions ("isIn",
207207
"isNotIn", etc.), if the list of values is empty, then the condition will still render, but the resulting SQL will
208208
be invalid and will cause a runtime exception. We believe this is the safest outcome. For example, suppose
209209
a DELETE statement was coded as follows:
@@ -220,7 +220,7 @@ This statement will be rendered as follows:
220220
delete from foo where status = ? and id in ()
221221
```
222222

223-
This will cause a runtime error due to invalid SQL, but it eliminates the possibility of deleting ALLs rows with
223+
This will cause a runtime error due to invalid SQL, but it eliminates the possibility of deleting ALL rows with
224224
active status. If you want to allow the "in" condition to drop from the SQL if the list is empty, then use the
225225
"inWhenPresent" condition.
226226

src/test/java/config/TestContainersConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
* Utility interface to hold Docker image tags for the test containers we use
2222
*/
2323
public interface TestContainersConfiguration {
24-
DockerImageName POSTGRES_LATEST = DockerImageName.parse("postgres:15.4");
25-
DockerImageName MARIADB_LATEST = DockerImageName.parse("mariadb:11.0.3");
24+
DockerImageName POSTGRES_LATEST = DockerImageName.parse("postgres:16.3");
25+
DockerImageName MARIADB_LATEST = DockerImageName.parse("mariadb:11.4.2");
2626
}

src/test/java/examples/animal/data/AnimalDataTest.java

Lines changed: 234 additions & 163 deletions
Large diffs are not rendered by default.

src/test/java/examples/animal/data/CommonSelectMapperTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class CommonSelectMapperTest {
5555
void setup() throws Exception {
5656
Class.forName(JDBC_DRIVER);
5757
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
58+
assert is != null;
5859
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
5960
ScriptRunner sr = new ScriptRunner(connection);
6061
sr.setLogWriter(null);

src/test/java/examples/animal/data/FetchFirstTest.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import static examples.animal.data.AnimalDataDynamicSqlSupport.*;
1919
import static org.assertj.core.api.Assertions.assertThat;
20+
import static org.assertj.core.api.Assertions.entry;
2021
import static org.junit.jupiter.api.Assertions.assertAll;
2122
import static org.mybatis.dynamic.sql.SqlBuilder.*;
2223

@@ -50,6 +51,7 @@ class FetchFirstTest {
5051
void setup() throws Exception {
5152
Class.forName(JDBC_DRIVER);
5253
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
54+
assert is != null;
5355
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
5456
ScriptRunner sr = new ScriptRunner(connection);
5557
sr.setLogWriter(null);
@@ -78,7 +80,7 @@ void testOffsetAndFetchFirstAfterFrom() {
7880

7981
assertAll(
8082
() -> assertThat(records).hasSize(3),
81-
() -> assertThat(records.get(0).getId()).isEqualTo(23),
83+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(23),
8284
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData offset #{parameters.p1} rows fetch first #{parameters.p2} rows only"),
8385
() -> assertThat(selectStatement.getParameters()).containsEntry("p2", 3L),
8486
() -> assertThat(selectStatement.getParameters()).containsEntry("p1", 22L)
@@ -100,7 +102,7 @@ void testFetchFirstOnlyAfterFrom() {
100102

101103
assertAll(
102104
() -> assertThat(records).hasSize(3),
103-
() -> assertThat(records.get(0).getId()).isEqualTo(1),
105+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(1),
104106
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData fetch first #{parameters.p1} rows only"),
105107
() -> assertThat(selectStatement.getParameters()).containsEntry("p1", 3L)
106108
);
@@ -124,10 +126,9 @@ void testOffsetAndFetchFirstAfterWhere() {
124126

125127
assertAll(
126128
() -> assertThat(records).hasSize(3),
127-
() -> assertThat(records.get(0).getId()).isEqualTo(45),
129+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(45),
128130
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData where id < #{parameters.p1,jdbcType=INTEGER} and id > #{parameters.p2,jdbcType=INTEGER} offset #{parameters.p3} rows fetch first #{parameters.p4} rows only"),
129-
() -> assertThat(selectStatement.getParameters()).containsEntry("p4", 3L),
130-
() -> assertThat(selectStatement.getParameters()).containsEntry("p3", 22L)
131+
() -> assertThat(selectStatement.getParameters()).contains(entry("p4", 3L), entry("p3", 22L))
131132
);
132133
}
133134
}
@@ -147,7 +148,7 @@ void testFetchFirstOnlyAfterWhere() {
147148

148149
assertAll(
149150
() -> assertThat(records).hasSize(3),
150-
() -> assertThat(records.get(0).getId()).isEqualTo(1),
151+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(1),
151152
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData where id < #{parameters.p1,jdbcType=INTEGER} fetch first #{parameters.p2} rows only"),
152153
() -> assertThat(selectStatement.getParameters()).containsEntry("p2", 3L)
153154
);
@@ -170,10 +171,12 @@ void testOffsetAndFetchFirstAfterOrderBy() {
170171

171172
assertAll(
172173
() -> assertThat(records).hasSize(3),
173-
() -> assertThat(records.get(0).getId()).isEqualTo(23),
174+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(23),
174175
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData order by id offset #{parameters.p1} rows fetch first #{parameters.p2} rows only"),
175-
() -> assertThat(selectStatement.getParameters()).containsEntry("p2", 3L),
176-
() -> assertThat(selectStatement.getParameters()).containsEntry("p1", 22L)
176+
() -> assertThat(selectStatement)
177+
.extracting(SelectStatementProvider::getParameters)
178+
.extracting("p2", "p1")
179+
.containsExactly(3L, 22L)
177180
);
178181
}
179182
}
@@ -193,7 +196,7 @@ void testLimitOnlyAfterOrderBy() {
193196

194197
assertAll(
195198
() -> assertThat(records).hasSize(3),
196-
() -> assertThat(records.get(0).getId()).isEqualTo(1),
199+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(1),
197200
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData order by id fetch first #{parameters.p1} rows only"),
198201
() -> assertThat(selectStatement.getParameters()).containsEntry("p1", 3L)
199202
);

src/test/java/examples/animal/data/LimitAndOffsetTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class LimitAndOffsetTest {
5050
void setup() throws Exception {
5151
Class.forName(JDBC_DRIVER);
5252
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
53+
assert is != null;
5354
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
5455
ScriptRunner sr = new ScriptRunner(connection);
5556
sr.setLogWriter(null);
@@ -78,7 +79,7 @@ void testLimitAndOffsetAfterFrom() {
7879

7980
assertAll(
8081
() -> assertThat(records).hasSize(3),
81-
() -> assertThat(records.get(0).getId()).isEqualTo(23),
82+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(23),
8283
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData limit #{parameters.p1} offset #{parameters.p2}"),
8384
() -> assertThat(selectStatement.getParameters()).containsEntry("p1", 3L),
8485
() -> assertThat(selectStatement.getParameters()).containsEntry("p2", 22L)
@@ -100,7 +101,7 @@ void testLimitOnlyAfterFrom() {
100101

101102
assertAll(
102103
() -> assertThat(records).hasSize(3),
103-
() -> assertThat(records.get(0).getId()).isEqualTo(1),
104+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(1),
104105
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData limit #{parameters.p1}"),
105106
() -> assertThat(selectStatement.getParameters()).containsEntry("p1", 3L)
106107
);
@@ -121,7 +122,7 @@ void testOffsetOnlyAfterFrom() {
121122

122123
assertAll(
123124
() -> assertThat(records).hasSize(43),
124-
() -> assertThat(records.get(0).getId()).isEqualTo(23),
125+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(23),
125126
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData offset #{parameters.p1} rows"),
126127
() -> assertThat(selectStatement.getParameters()).containsEntry("p1", 22L)
127128
);
@@ -145,7 +146,7 @@ void testLimitAndOffsetAfterWhere() {
145146

146147
assertAll(
147148
() -> assertThat(records).hasSize(3),
148-
() -> assertThat(records.get(0).getId()).isEqualTo(45),
149+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(45),
149150
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData where id < #{parameters.p1,jdbcType=INTEGER} and id > #{parameters.p2,jdbcType=INTEGER} limit #{parameters.p3} offset #{parameters.p4}"),
150151
() -> assertThat(selectStatement.getParameters()).containsEntry("p3", 3L),
151152
() -> assertThat(selectStatement.getParameters()).containsEntry("p4", 22L)
@@ -168,7 +169,7 @@ void testLimitOnlyAfterWhere() {
168169

169170
assertAll(
170171
() -> assertThat(records).hasSize(3),
171-
() -> assertThat(records.get(0).getId()).isEqualTo(1),
172+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(1),
172173
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData where id < #{parameters.p1,jdbcType=INTEGER} limit #{parameters.p2}"),
173174
() -> assertThat(selectStatement.getParameters()).containsEntry("p2", 3L)
174175
);
@@ -190,7 +191,7 @@ void testOffsetOnlyAfterWhere() {
190191

191192
assertAll(
192193
() -> assertThat(records).hasSize(27),
193-
() -> assertThat(records.get(0).getId()).isEqualTo(23),
194+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(23),
194195
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData where id < #{parameters.p1,jdbcType=INTEGER} offset #{parameters.p2} rows"),
195196
() -> assertThat(selectStatement.getParameters()).containsEntry("p2", 22L)
196197
);
@@ -213,7 +214,7 @@ void testLimitAndOffsetAfterOrderBy() {
213214

214215
assertAll(
215216
() -> assertThat(records).hasSize(3),
216-
() -> assertThat(records.get(0).getId()).isEqualTo(23),
217+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(23),
217218
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData order by id limit #{parameters.p1} offset #{parameters.p2}"),
218219
() -> assertThat(selectStatement.getParameters()).containsEntry("p1", 3L),
219220
() -> assertThat(selectStatement.getParameters()).containsEntry("p2", 22L)
@@ -236,7 +237,7 @@ void testLimitOnlyAfterOrderBy() {
236237

237238
assertAll(
238239
() -> assertThat(records).hasSize(3),
239-
() -> assertThat(records.get(0).getId()).isEqualTo(1),
240+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(1),
240241
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData order by id limit #{parameters.p1}"),
241242
() -> assertThat(selectStatement.getParameters()).containsEntry("p1", 3L)
242243
);
@@ -258,7 +259,7 @@ void testOffsetOnlyAfterOrderBy() {
258259

259260
assertAll(
260261
() -> assertThat(records).hasSize(43),
261-
() -> assertThat(records.get(0).getId()).isEqualTo(23),
262+
() -> assertThat(records).first().isNotNull().extracting(AnimalData::getId).isEqualTo(23),
262263
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select * from AnimalData order by id offset #{parameters.p1} rows"),
263264
() -> assertThat(selectStatement.getParameters()).containsEntry("p1", 22L)
264265
);

0 commit comments

Comments
 (0)