@@ -480,6 +480,39 @@ function convertHints(hints) {
480480 return result ;
481481}
482482
483+ /**
484+ * Convert rust ComplexType into type representation used in the driver encoder
485+ * @param {rust.ComplexType } type
486+ */
487+ function convertComplexType ( type ) {
488+ let data = {
489+ code : type . baseType . valueOf ( ) ,
490+ } ;
491+ let fistSupport = type . getFirstSupportType ( ) ;
492+ let secondSupport = type . getSecondSupportType ( ) ;
493+ let otherTypes = type . getInnerTypes ( ) ;
494+ if ( fistSupport != null ) {
495+ data . info = convertComplexType ( fistSupport ) ;
496+ if ( secondSupport != null ) {
497+ data . info = [ data . info , convertComplexType ( secondSupport ) ] ;
498+ }
499+ } else if ( otherTypes . length > 0 ) {
500+ if ( data . code == rust . CqlType . UserDefinedType ) {
501+ let names = type . getUdtFieldNames ( ) ;
502+ data . info = {
503+ fields : otherTypes . map ( ( typ , index ) => {
504+ let obj = { type : convertComplexType ( typ ) } ;
505+ obj . name = names [ index ] ;
506+ return obj ;
507+ } ) ,
508+ } ;
509+ } else {
510+ data . info = otherTypes . map ( ( t ) => convertComplexType ( t ) ) ;
511+ }
512+ }
513+ return data ;
514+ }
515+
483516/**
484517 *
485518 * @param {null | object | Array<object> } object
@@ -495,6 +528,7 @@ function rustConvertHint(object) {
495528module . exports . parseParams = parseParams ;
496529module . exports . convertHints = convertHints ;
497530module . exports . rustConvertHint = rustConvertHint ;
531+ module . exports . convertComplexType = convertComplexType ;
498532
499533// For unit test usage
500534module . exports . getWrapped = getWrapped ;
0 commit comments