Use first column in case of duplicate columns.

Also, fallback on column names when label is not present.

See #1680
Original pull request #1825
This commit is contained in:
Jens Schauder
2024-07-01 13:30:58 +02:00
parent eaaf1257ba
commit 448b6fd617
@@ -73,8 +73,8 @@ class RowDocumentResultSetExtractor {
for (int i = 0; i < columnCount; i++) {
Object rsv = JdbcUtils.getResultSetValue(resultSet, i + 1);
String columnName = md.getColumnLabel(i + 1);
Object old = document.put(columnName, rsv instanceof Array a ? a.getArray() : rsv);
String columnName = JdbcUtils.lookupColumnName(md, i+1);
Object old = document.putIfAbsent(columnName, rsv instanceof Array a ? a.getArray() : rsv);
if (old != null) {
log.warn(DUPLICATE_COLUMN_WARNING, columnName, i);
}