Skip to content

Commit

Permalink
[#1984] Return typeName column metadata for results
Browse files Browse the repository at this point in the history
This information is now available and it's required when working with JSON.
  • Loading branch information
DavideD committed Sep 26, 2024
1 parent 3336e33 commit 0680041
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1323,10 +1323,25 @@ private static class MetaData implements ResultSetMetaData {

private final List<String> columns;
private final List<ColumnDescriptor> descriptors;
private final String[] typeNames;


public MetaData(List<String> columnNames, List<ColumnDescriptor> columnDescriptors) {
columns = columnNames;
descriptors = columnDescriptors;
typeNames = initTypeNames( columnDescriptors );
}

private static String[] initTypeNames(List<ColumnDescriptor> columnDescriptors) {
if ( columnDescriptors == null ) {
return null;
}
final String[] typeNames = new String[columnDescriptors.size()];
int i = 0;
for ( ColumnDescriptor columnDescriptor : columnDescriptors ) {
typeNames[i++] = columnDescriptor.typeName();
}
return typeNames;
}

@Override
Expand Down Expand Up @@ -1412,9 +1427,7 @@ public String getCatalogName(int column) {

@Override
public String getColumnTypeName(int column) {
// This information is in rows.columnDescriptors().get( column-1 ).dataType.name
// but does not appear to be accessible.
return null;
return typeNames[column - 1];
}

@Override
Expand Down

0 comments on commit 0680041

Please sign in to comment.