Skip to content

Commit c13e19b

Browse files
authored
Merge pull request #1063 from jeffgbutler/code-ql-fixes
CodeQL Fixes
2 parents 72a21ea + 738f59b commit c13e19b

30 files changed

Lines changed: 248 additions & 206 deletions

src/main/java/org/mybatis/dynamic/sql/dsl/AbstractDeleteDSL.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
public abstract class AbstractDeleteDSL<M, D extends AbstractDeleteDSL<M, D>>
4141
implements WhereOperations<AbstractDeleteDSL<M, D>.DeleteWhereBuilder>,
4242
ConfigurableStatement<D>,
43+
OrderByOperations<D>,
4344
Buildable<M> {
4445
private final SqlTable table;
4546
private final @Nullable String tableAlias;
@@ -82,10 +83,7 @@ public D limitWhenPresent(@Nullable Long limit) {
8283
return getThis();
8384
}
8485

85-
public D orderBy(SortSpecification... columns) {
86-
return orderBy(Arrays.asList(columns));
87-
}
88-
86+
@Override
8987
public D orderBy(Collection<? extends SortSpecification> columns) {
9088
orderByModel = OrderByModel.of(columns);
9189
return getThis();

src/main/java/org/mybatis/dynamic/sql/dsl/AbstractUpdateDSL.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
public abstract class AbstractUpdateDSL<M, D extends AbstractUpdateDSL<M, D>>
5454
implements WhereOperations<AbstractUpdateDSL<M, D>.UpdateWhereBuilder>,
55+
OrderByOperations<D>,
5556
ConfigurableStatement<D>,
5657
Buildable<M> {
5758

@@ -101,10 +102,7 @@ public D limitWhenPresent(@Nullable Long limit) {
101102
return getThis();
102103
}
103104

104-
public D orderBy(SortSpecification... columns) {
105-
return orderBy(Arrays.asList(columns));
106-
}
107-
105+
@Override
108106
public D orderBy(Collection<? extends SortSpecification> columns) {
109107
orderByModel = OrderByModel.of(columns);
110108
return getThis();

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ class AnimalDataTest {
7676
@BeforeEach
7777
void setup() throws Exception {
7878
Class.forName(JDBC_DRIVER);
79-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
80-
assert is != null;
81-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
82-
ScriptRunner sr = new ScriptRunner(connection);
83-
sr.setLogWriter(null);
84-
sr.runScript(new InputStreamReader(is));
79+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
80+
assert is != null;
81+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
82+
InputStreamReader isr = new InputStreamReader(is)) {
83+
ScriptRunner sr = new ScriptRunner(connection);
84+
sr.setLogWriter(null);
85+
sr.runScript(isr);
86+
}
8587
}
8688

8789
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,12 +50,14 @@ class BindingTest {
5050
@BeforeEach
5151
void setup() throws Exception {
5252
Class.forName(JDBC_DRIVER);
53-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
54-
assert is != null;
55-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
56-
ScriptRunner sr = new ScriptRunner(connection);
57-
sr.setLogWriter(null);
58-
sr.runScript(new InputStreamReader(is));
53+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
54+
assert is != null;
55+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
56+
InputStreamReader isr = new InputStreamReader(is)) {
57+
ScriptRunner sr = new ScriptRunner(connection);
58+
sr.setLogWriter(null);
59+
sr.runScript(isr);
60+
}
5961
}
6062

6163
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,12 +72,14 @@ class CaseExpressionTest {
7272
@BeforeEach
7373
void setup() throws Exception {
7474
Class.forName(JDBC_DRIVER);
75-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
76-
assert is != null;
77-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
78-
ScriptRunner sr = new ScriptRunner(connection);
79-
sr.setLogWriter(null);
80-
sr.runScript(new InputStreamReader(is));
75+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
76+
assert is != null;
77+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
78+
InputStreamReader isr = new InputStreamReader(is)) {
79+
ScriptRunner sr = new ScriptRunner(connection);
80+
sr.setLogWriter(null);
81+
sr.runScript(isr);
82+
}
8183
}
8284

8385
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,12 +54,14 @@ class CommonSelectMapperTest {
5454
@BeforeEach
5555
void setup() throws Exception {
5656
Class.forName(JDBC_DRIVER);
57-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
58-
assert is != null;
59-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
60-
ScriptRunner sr = new ScriptRunner(connection);
61-
sr.setLogWriter(null);
62-
sr.runScript(new InputStreamReader(is));
57+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
58+
assert is != null;
59+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
60+
InputStreamReader isr = new InputStreamReader(is)) {
61+
ScriptRunner sr = new ScriptRunner(connection);
62+
sr.setLogWriter(null);
63+
sr.runScript(isr);
64+
}
6365
}
6466

6567
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,12 +50,14 @@ class FetchFirstTest {
5050
@BeforeEach
5151
void setup() throws Exception {
5252
Class.forName(JDBC_DRIVER);
53-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
54-
assert is != null;
55-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
56-
ScriptRunner sr = new ScriptRunner(connection);
57-
sr.setLogWriter(null);
58-
sr.runScript(new InputStreamReader(is));
53+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
54+
assert is != null;
55+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
56+
InputStreamReader isr = new InputStreamReader(is)) {
57+
ScriptRunner sr = new ScriptRunner(connection);
58+
sr.setLogWriter(null);
59+
sr.runScript(isr);
60+
}
5961
}
6062

6163
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,12 +49,14 @@ class LimitAndOffsetTest {
4949
@BeforeEach
5050
void setup() throws Exception {
5151
Class.forName(JDBC_DRIVER);
52-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
53-
assert is != null;
54-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
55-
ScriptRunner sr = new ScriptRunner(connection);
56-
sr.setLogWriter(null);
57-
sr.runScript(new InputStreamReader(is));
52+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
53+
assert is != null;
54+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
55+
InputStreamReader isr = new InputStreamReader(is)) {
56+
ScriptRunner sr = new ScriptRunner(connection);
57+
sr.setLogWriter(null);
58+
sr.runScript(isr);
59+
}
5860
}
5961

6062
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,12 +51,14 @@ class OptionalConditionsAnimalDataTest {
5151
@BeforeEach
5252
void setup() throws Exception {
5353
Class.forName(JDBC_DRIVER);
54-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
55-
assert is != null;
56-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
57-
ScriptRunner sr = new ScriptRunner(connection);
58-
sr.setLogWriter(null);
59-
sr.runScript(new InputStreamReader(is));
54+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
55+
assert is != null;
56+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
57+
InputStreamReader isr = new InputStreamReader(is)) {
58+
ScriptRunner sr = new ScriptRunner(connection);
59+
sr.setLogWriter(null);
60+
sr.runScript(isr);
61+
}
6062
}
6163

6264
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,12 +57,14 @@ class OptionalConditionsWithPredicatesAnimalDataTest {
5757
@BeforeEach
5858
void setup() throws Exception {
5959
Class.forName(JDBC_DRIVER);
60-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
61-
assert is != null;
62-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
63-
ScriptRunner sr = new ScriptRunner(connection);
64-
sr.setLogWriter(null);
65-
sr.runScript(new InputStreamReader(is));
60+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
61+
assert is != null;
62+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
63+
InputStreamReader isr = new InputStreamReader(is)) {
64+
ScriptRunner sr = new ScriptRunner(connection);
65+
sr.setLogWriter(null);
66+
sr.runScript(isr);
67+
}
6668
}
6769

6870
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

0 commit comments

Comments
 (0)