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 {
641
641
. await ;
642
642
643
643
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
+ }
645
651
Err ( e) => match e. as_database_error ( ) {
646
652
Some ( d) => {
647
653
if d. code ( ) == Some ( Cow :: from ( "XX000" ) ) {
@@ -655,7 +661,11 @@ impl Collection {
655
661
let results: ( Json , ) = sqlx:: query_as_with ( & built_query, values)
656
662
. fetch_one ( & pool)
657
663
. 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)
659
669
} else {
660
670
Err ( anyhow:: anyhow!( e) )
661
671
}
@@ -672,7 +682,11 @@ impl Collection {
672
682
let results: ( Json , ) = sqlx:: query_as_with ( & built_query, values)
673
683
. fetch_one ( & pool)
674
684
. 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)
676
690
}
677
691
678
692
#[ instrument( skip( self ) ) ]
You can’t perform that action at this time.
0 commit comments