File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -641,7 +641,13 @@ impl Collection {
641641 . await ;
642642
643643 match results {
644- Ok ( r) => Ok ( r. 0 ) ,
644+ Ok ( r) => {
645+ let mut results = r. 0 ;
646+ if results[ "results" ] . is_null ( ) {
647+ results[ "results" ] = json ! ( [ ] ) ;
648+ }
649+ Ok ( results)
650+ }
645651 Err ( e) => match e. as_database_error ( ) {
646652 Some ( d) => {
647653 if d. code ( ) == Some ( Cow :: from ( "XX000" ) ) {
@@ -655,7 +661,11 @@ impl Collection {
655661 let results: ( Json , ) = sqlx:: query_as_with ( & built_query, values)
656662 . fetch_one ( & pool)
657663 . await ?;
658- Ok ( results. 0 )
664+ let mut results = results. 0 ;
665+ if results[ "results" ] . is_null ( ) {
666+ results[ "results" ] = json ! ( [ ] ) ;
667+ }
668+ Ok ( results)
659669 } else {
660670 Err ( anyhow:: anyhow!( e) )
661671 }
@@ -672,7 +682,11 @@ impl Collection {
672682 let results: ( Json , ) = sqlx:: query_as_with ( & built_query, values)
673683 . fetch_one ( & pool)
674684 . await ?;
675- Ok ( results. 0 )
685+ let mut results = results. 0 ;
686+ if results[ "results" ] . is_null ( ) {
687+ results[ "results" ] = json ! ( [ ] ) ;
688+ }
689+ Ok ( results)
676690 }
677691
678692 #[ instrument( skip( self ) ) ]
You can’t perform that action at this time.
0 commit comments