44
44
import com .apple .foundationdb .relational .jdbc .grpc .v1 .column .ListColumn ;
45
45
import com .apple .foundationdb .relational .jdbc .grpc .v1 .column .ListColumnMetadata ;
46
46
import com .apple .foundationdb .relational .jdbc .grpc .v1 .column .Struct ;
47
+ import com .apple .foundationdb .relational .jdbc .grpc .v1 .column .Uuid ;
47
48
import com .apple .foundationdb .relational .util .PositionalIndex ;
48
49
import com .google .common .annotations .VisibleForTesting ;
49
50
import com .google .protobuf .ByteString ;
54
55
import java .util .ArrayList ;
55
56
import java .util .List ;
56
57
import java .util .Map ;
58
+ import java .util .UUID ;
57
59
import java .util .function .BiFunction ;
58
60
59
61
/**
@@ -80,6 +82,14 @@ static RelationalStruct getStruct(ResultSet resultSet, int rowIndex, int oneBase
80
82
return column .hasStruct () ? new RelationalStructFacade (metadata , column .getStruct ()) : null ;
81
83
}
82
84
85
+ static UUID getUUID (ResultSet resultSet , int rowIndex , int oneBasedColumn ) throws SQLException {
86
+ int index = PositionalIndex .toProtobuf (oneBasedColumn );
87
+ var metadata =
88
+ resultSet .getMetadata ().getColumnMetadata ().getColumnMetadata (index ).getStructMetadata ();
89
+ Column column = resultSet .getRow (rowIndex ).getColumns ().getColumn (index );
90
+ return column .hasUuid () ? new UUID (column .getUuid ().getMostSignificantBits (), column .getUuid ().getLeastSignificantBits ()) : null ;
91
+ }
92
+
83
93
/**
84
94
* Convert list of {@link RelationalStruct} to {@link ResultSet}.
85
95
* @param structs List of {@link RelationalStruct} which are expected to be of type {@link RelationalStructFacade}.
@@ -415,6 +425,13 @@ private static Column toColumn(RelationalStruct relationalStruct, int oneBasedIn
415
425
column = toColumn (relationalStruct .wasNull () ? null : (String ) object ,
416
426
(value , protobuf ) -> value == null ? protobuf .clearString () : protobuf .setString (value ));
417
427
break ;
428
+ } else if (object instanceof UUID ) {
429
+ column = toColumn (relationalStruct .wasNull () ? null : (UUID ) object , (value , protobuf ) ->
430
+ value == null ? protobuf .clearUuid () : protobuf .setUuid (Uuid .newBuilder ()
431
+ .setMostSignificantBits (value .getMostSignificantBits ())
432
+ .setLeastSignificantBits (value .getLeastSignificantBits ())
433
+ .build ()));
434
+ break ;
418
435
}
419
436
if (object == null ) {
420
437
column = toColumn (null , (value , protobuf ) -> protobuf .clearString ());
0 commit comments