File tree 3 files changed +14
-2
lines changed
main/java/com/ing/data/cassandra/jdbc
test/java/com/ing/data/cassandra/jdbc
3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
14
14
### Fixed
15
15
- Add codec for conversion between ` Short ` and CQL type ` tinyint ` (see issue
16
16
[ #76 ] ( https://github.com/ing-bank/cassandra-jdbc-wrapper/issues/76 ) ).
17
+ - Handle lists of User-Defined Types (UDT) properly when using ` CassandraResultSet.getObject(String|int) ` methods (see
18
+ issue [ #76 ] ( https://github.com/ing-bank/cassandra-jdbc-wrapper/issues/76 ) ).
17
19
18
20
## [ 4.14.0] - 2024-12-24
19
21
### Added
Original file line number Diff line number Diff line change @@ -934,7 +934,10 @@ public Object getObject(final int columnIndex) throws SQLException {
934
934
final DataType elementsType = listType .getElementType ();
935
935
final List <?> resultList ;
936
936
937
- if (elementsType instanceof TupleType ) {
937
+ if (elementsType instanceof UserDefinedType ) {
938
+ resultList = this .currentRow .getList (columnIndex - 1 ,
939
+ TypesMap .getTypeForComparator (DataTypeEnum .UDT .asLowercaseCql ()).getType ());
940
+ } else if (elementsType instanceof TupleType ) {
938
941
resultList = this .currentRow .getList (columnIndex - 1 ,
939
942
TypesMap .getTypeForComparator (DataTypeEnum .TUPLE .asLowercaseCql ()).getType ());
940
943
} else {
@@ -1069,7 +1072,10 @@ public Object getObject(final String columnLabel) throws SQLException {
1069
1072
final DataType elementsType = listType .getElementType ();
1070
1073
final List <?> resultList ;
1071
1074
1072
- if (elementsType instanceof TupleType ) {
1075
+ if (elementsType instanceof UserDefinedType ) {
1076
+ resultList = this .currentRow .getList (columnLabel ,
1077
+ TypesMap .getTypeForComparator (DataTypeEnum .UDT .asLowercaseCql ()).getType ());
1078
+ } else if (elementsType instanceof TupleType ) {
1073
1079
resultList = this .currentRow .getList (columnLabel ,
1074
1080
TypesMap .getTypeForComparator (DataTypeEnum .TUPLE .asLowercaseCql ()).getType ());
1075
1081
} else {
Original file line number Diff line number Diff line change 38
38
import static org .hamcrest .CoreMatchers .is ;
39
39
import static org .hamcrest .MatcherAssert .assertThat ;
40
40
import static org .hamcrest .Matchers .instanceOf ;
41
+ import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
41
42
import static org .junit .jupiter .api .Assertions .assertEquals ;
42
43
import static org .junit .jupiter .api .Assertions .assertFalse ;
43
44
import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
@@ -356,6 +357,9 @@ void givenFrozenTypesSelectStatement_whenExecute_getExpectedResultSet() throws E
356
357
assertEquals ("test" , udtValue .getString ("value1" ));
357
358
assertTrue (udtValue .getBoolean ("value2" ));
358
359
360
+ // Check retrieving a list of UDTs does not throw an exception (see issue #76).
361
+ assertDoesNotThrow (() -> resultSet .getObject ("innerUdt" ));
362
+
359
363
Object outerUdt = resultSet .getObject ("outerUdt" );
360
364
assertInstanceOf (UdtValue .class , outerUdt );
361
365
assertEquals (1 , ((UdtValue ) outerUdt ).getInt ("key" ));
You can’t perform that action at this time.
0 commit comments