Skip to content

Commit 87a4b55

Browse files
authored
Replace getColumnName() with getColumnLabel() (#112)
1 parent 771ccd1 commit 87a4b55

File tree

8 files changed

+39
-3
lines changed

8 files changed

+39
-3
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
- node/install:
104104
node-version: << pipeline.parameters.node-version >>
105105
- setup_remote_docker:
106-
version: 19.03.13
106+
version: default
107107
docker_layer_caching: true
108108
# build and push Docker image
109109
- run:

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.5.10 (June 27, 2025)
2+
* Fixed the issue with aliases in the `Select Query` action ([#Issue 111](https://github.com/elasticio/jdbc-component/issues/111))
3+
14
## 2.5.9 (August 01, 2024)
25
* Bumped Sailor to 4.0.3
36
*

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ FROM users
164164
WHERE userid = @id:number AND language = @lang:string
165165
```
166166

167+
You can use aliases too:
168+
```sql
169+
SELECT users.id AS internal_id
170+
FROM internal_users users
171+
```
172+
167173
Following types are supported:
168174
* ``string``
169175
* ``number``

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ test {
4141
task integrationTest(type: Test) {
4242
testLogging {
4343
showStandardStreams = true
44+
exceptionFormat "full"
4445
}
4546
filter() {
4647
includeTestsMatching "io.elastic.jdbc.integration.*"

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"title": "Database",
33
"description": "Database JDBC connector",
4-
"version": "2.5.9",
4+
"version": "2.5.10",
55
"credentials": {
66
"verifier": "io.elastic.jdbc.JdbcCredentialsVerifier",
77
"fields": {

dependencyCheck-suppression.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
<packageUrl regex="true">^pkg:maven/com\.google\.protobuf/protobuf\-java@.*$</packageUrl>
1818
<cve>CVE-2022-3171</cve>
1919
</suppress>
20+
<suppress>
21+
<notes><![CDATA[
22+
file name: protobuf-java-3.25.1.jar
23+
]]>
24+
</notes>
25+
<packageUrl regex="true">^pkg:maven/com\.google\.protobuf/protobuf\-java@.*$</packageUrl>
26+
<cve>CVE-2024-7254</cve>
27+
</suppress>
2028
<suppress>
2129
<notes><![CDATA[
2230
file name: logback-json-classic-0.1.5.jar

src/main/java/io/elastic/jdbc/utils/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public static Map<String, String> getVariableTypes(String sqlQuery) {
298298
public static JsonObjectBuilder getColumnDataByType(ResultSet rs, ResultSetMetaData metaData,
299299
int i, JsonObjectBuilder row) {
300300
try {
301-
final String columnName = metaData.getColumnName(i);
301+
final String columnName = metaData.getColumnLabel(i);
302302
if (null == rs.getObject(columnName)) {
303303
row.add(columnName, JsonValue.NULL);
304304
return row;

src/test/groovy/io/elastic/jdbc/integration/actions/select_action/SelectMySQLSpec.groovy

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ class SelectMySQLSpec extends Specification {
8585
return config;
8686
}
8787

88+
def getAliasStarsConfig() {
89+
JsonObject config = TestUtils.getMysqlConfigurationBuilder()
90+
.add("sqlQuery", "SELECT strs.id AS strsid from stars strs")
91+
.build()
92+
return config;
93+
}
94+
8895
def prepareStarsTable() {
8996
String sql = "DROP TABLE IF EXISTS stars"
9097
connection.createStatement().execute(sql);
@@ -112,4 +119,15 @@ class SelectMySQLSpec extends Specification {
112119
0 * errorCallback.receive(_)
113120
}
114121

122+
def "select with alias"() {
123+
prepareStarsTable();
124+
JsonObject snapshot = Json.createObjectBuilder().build();
125+
JsonObject body = Json.createObjectBuilder()
126+
.build()
127+
when:
128+
runAction(getAliasStarsConfig(), body, snapshot)
129+
then:
130+
0 * errorCallback.receive(_)
131+
}
132+
115133
}

0 commit comments

Comments
 (0)