File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ use sqlx::{
3030} ;
3131
3232use self :: sql:: ParsedSQLStatement ;
33+ use self :: sql_to_json:: sql_to_json;
3334use sql_pseudofunctions:: StmtParam ;
3435
3536pub struct Database {
@@ -160,8 +161,21 @@ fn vars_and_name<'a>(
160161}
161162
162163fn row_to_varvalue ( row : & AnyRow ) -> SingleOrVec {
163- row. try_get :: < String , usize > ( 0 )
164- . map_or_else ( |_| SingleOrVec :: Vec ( vec ! [ ] ) , SingleOrVec :: Single )
164+ let Some ( col) = row. columns ( ) . first ( ) else {
165+ return SingleOrVec :: Single ( String :: new ( ) ) ;
166+ } ;
167+ match sql_to_json ( row, col) {
168+ Value :: String ( s) => SingleOrVec :: Single ( s) ,
169+ Value :: Array ( vals) => SingleOrVec :: Vec (
170+ vals. into_iter ( )
171+ . map ( |v| match v {
172+ Value :: String ( s) => s,
173+ other => other. to_string ( ) ,
174+ } )
175+ . collect ( ) ,
176+ ) ,
177+ other => SingleOrVec :: Single ( other. to_string ( ) ) ,
178+ }
165179}
166180
167181async fn take_connection < ' a , ' b > (
You can’t perform that action at this time.
0 commit comments