@@ -208,9 +208,9 @@ pub struct TsQuery {
208208 pub annotated_params : BTreeMap < usize , TsFieldType > ,
209209
210210 // We use BTreeMap here as it's a collection that's already sorted
211- pub insert_params : BTreeMap < usize , BTreeMap < usize , TsFieldType > > ,
211+ pub insert_params : BTreeMap < usize , BTreeMap < usize , Vec < TsFieldType > > > ,
212212 // Holds any annotated @param and perform replacement when generated TS types
213- pub annotated_insert_params : BTreeMap < usize , BTreeMap < usize , TsFieldType > > ,
213+ pub annotated_insert_params : BTreeMap < usize , BTreeMap < usize , Vec < TsFieldType > > > ,
214214
215215 pub result : HashMap < String , Vec < TsFieldType > > ,
216216 // Holds any annotated @result and perform replacement when generating TS types
@@ -319,7 +319,13 @@ impl TsQuery {
319319 ///
320320 /// e.g.
321321 /// [ [number, string], [number, string] ]
322- pub fn insert_value_params ( & mut self , value : & TsFieldType , point : & ( usize , usize ) , _placeholder : & Option < String > ) {
322+ pub fn insert_value_params (
323+ & mut self ,
324+ value : & TsFieldType ,
325+ point : & ( usize , usize ) ,
326+ is_nullable : bool ,
327+ _placeholder : & Option < String > ,
328+ ) {
323329 let ( row, column) = point;
324330 let annotated_insert_param = self . annotated_insert_params . get ( row) ;
325331
@@ -334,7 +340,11 @@ impl TsQuery {
334340 row_params = self . insert_params . get_mut ( row) ;
335341 }
336342
337- row_params. unwrap ( ) . insert ( * column, value. to_owned ( ) ) ;
343+ let mut types = vec ! [ value. to_owned( ) ] ;
344+ if is_nullable {
345+ types. push ( TsFieldType :: Null ) ;
346+ }
347+ row_params. unwrap ( ) . insert ( * column, types) ;
338348 }
339349 }
340350
@@ -397,7 +407,10 @@ impl TsQuery {
397407 // Process each row and produce Number, String, Boolean
398408 row
399409 . values ( )
400- . map ( |col| col. to_string ( ) )
410+ . map ( |col| {
411+ let type_strings = col. iter ( ) . map ( |t| t. to_string ( ) ) . collect :: < Vec < _ > > ( ) ;
412+ type_strings. join ( " | " ) . to_string ( )
413+ } )
401414 . collect :: < Vec < String > > ( )
402415 . join ( ", " )
403416 } )
0 commit comments