@@ -869,19 +869,17 @@ impl ConnectionBuilder {
869869 let frags: Vec < String > = self
870870 . selections
871871 . iter ( )
872- . map ( |x| {
872+ . filter_map ( |x| {
873873 x. to_sql (
874874 quoted_block_name,
875875 & self . order_by ,
876876 & self . source . table ,
877877 param_context,
878- )
878+ ) . transpose ( )
879879 } )
880880 . collect :: < Result < Vec < _ > , _ > > ( ) ?;
881881
882- // Filter out empty strings from ConnectionSelection::Aggregate to_sql
883- let non_empty_frags: Vec < String > = frags. into_iter ( ) . filter ( |s| !s. is_empty ( ) ) . collect ( ) ;
884- Ok ( non_empty_frags. join ( ", " ) )
882+ Ok ( frags. join ( ", " ) )
885883 }
886884
887885 fn limit_clause ( & self ) -> u64 {
@@ -1314,32 +1312,30 @@ impl ConnectionSelection {
13141312 order_by : & OrderByBuilder ,
13151313 table : & Table ,
13161314 param_context : & mut ParamContext ,
1317- ) -> Result < String , String > {
1315+ ) -> Result < Option < String > , String > {
13181316 Ok ( match self {
1319- Self :: Edge ( x) => {
1320- format ! (
1321- "{}, {}" ,
1322- quote_literal( & x. alias) ,
1323- x. to_sql( block_name, order_by, table, param_context) ?
1324- )
1325- }
1326- Self :: PageInfo ( x) => {
1327- format ! (
1328- "{}, {}" ,
1329- quote_literal( & x. alias) ,
1330- x. to_sql( block_name, order_by, table) ?
1331- )
1332- }
1333- Self :: TotalCount { alias } => {
1334- format ! (
1335- "{}, coalesce(__total_count.___total_count, 0)" ,
1336- quote_literal( alias) ,
1337- )
1338- }
1339- Self :: Typename { alias, typename } => {
1340- format ! ( "{}, {}" , quote_literal( alias) , quote_literal( typename) )
1341- }
1342- Self :: Aggregate ( builder) => builder. to_sql ( block_name, param_context) ?,
1317+ Self :: Edge ( x) => Some ( format ! (
1318+ "{}, {}" ,
1319+ quote_literal( & x. alias) ,
1320+ x. to_sql( block_name, order_by, table, param_context) ?
1321+ ) ) ,
1322+ Self :: PageInfo ( x) => Some ( format ! (
1323+ "{}, {}" ,
1324+ quote_literal( & x. alias) ,
1325+ x. to_sql( block_name, order_by, table) ?
1326+ ) ) ,
1327+ Self :: TotalCount { alias } => Some ( format ! (
1328+ "{}, coalesce(__total_count.___total_count, 0)" ,
1329+ quote_literal( alias) ,
1330+ ) ) ,
1331+ Self :: Typename { alias, typename } => Some ( format ! (
1332+ "{}, {}" ,
1333+ quote_literal( alias) ,
1334+ quote_literal( typename)
1335+ ) ) ,
1336+ // SQL generation is handled by ConnectionBuilder::aggregate_select_list
1337+ // and the results are merged in later in the process
1338+ Self :: Aggregate ( _) => None ,
13431339 } )
13441340 }
13451341}
@@ -1922,18 +1918,6 @@ impl Serialize for __EnumValueBuilder {
19221918 }
19231919}
19241920
1925- impl AggregateBuilder {
1926- pub fn to_sql (
1927- & self ,
1928- _block_name : & str ,
1929- _param_context : & mut ParamContext ,
1930- ) -> Result < String , String > {
1931- // SQL generation is handled by ConnectionBuilder::aggregate_select_list
1932- // and the results are merged in later in the process
1933- Ok ( String :: new ( ) )
1934- }
1935- }
1936-
19371921#[ cfg( any( test, feature = "pg_test" ) ) ]
19381922#[ pgrx:: pg_schema]
19391923mod tests {
0 commit comments