@@ -3145,8 +3145,7 @@ pub enum ChildKey<'a> {
31453145 Single ( ChildKeyDetails < ' a > ) ,
31463146 /// First column is the primary key of the parent
31473147 Many ( dsl:: Column < ' a > , Vec < ChildKeyDetails < ' a > > ) ,
3148- IdAsc ( ChildIdDetails < ' a > , UseBlockColumn ) ,
3149- IdDesc ( ChildIdDetails < ' a > , UseBlockColumn ) ,
3148+ Id ( SortDirection , ChildIdDetails < ' a > , UseBlockColumn ) ,
31503149 ManyIdAsc ( Vec < ChildIdDetails < ' a > > , UseBlockColumn ) ,
31513150 ManyIdDesc ( Vec < ChildIdDetails < ' a > > , UseBlockColumn ) ,
31523151}
@@ -3238,24 +3237,13 @@ impl<'a> fmt::Display for SortKey<'a> {
32383237 } )
32393238 }
32403239
3241- ChildKey :: IdAsc ( details, UseBlockColumn :: No ) => {
3242- write ! ( f, "{}" , details. child_table. primary_key( ) )
3240+ ChildKey :: Id ( direction , details, UseBlockColumn :: No ) => {
3241+ write ! ( f, "{}{} " , details. child_table. primary_key( ) , direction )
32433242 }
3244- ChildKey :: IdAsc ( details, UseBlockColumn :: Yes ) => {
3243+ ChildKey :: Id ( direction , details, UseBlockColumn :: Yes ) => {
32453244 write ! (
32463245 f,
3247- "{}, {}" ,
3248- details. child_table. primary_key( ) ,
3249- details. child_br
3250- )
3251- }
3252- ChildKey :: IdDesc ( details, UseBlockColumn :: No ) => {
3253- write ! ( f, "{} desc" , details. child_table. primary_key( ) , )
3254- }
3255- ChildKey :: IdDesc ( details, UseBlockColumn :: Yes ) => {
3256- write ! (
3257- f,
3258- "{} desc, {} desc" ,
3246+ "{}{direction}, {}{direction}" ,
32593247 details. child_table. primary_key( ) ,
32603248 details. child_br
32613249 )
@@ -3391,33 +3379,20 @@ impl<'a> SortKey<'a> {
33913379 let child_pk = child_table. primary_key ( ) ;
33923380 let child_br = child_table. block_column ( ) ;
33933381 let child_at_block = child_table. at_block ( block) ;
3394- use SortDirection :: * ;
3395- return match direction {
3396- Asc => Ok ( SortKey :: ChildKey ( ChildKey :: IdAsc (
3397- ChildIdDetails {
3398- child_table,
3399- child_from,
3400- parent_join_column : parent_column,
3401- child_join_column : child_column,
3402- child_pk,
3403- child_br,
3404- child_at_block,
3405- } ,
3406- use_block_column,
3407- ) ) ) ,
3408- Desc => Ok ( SortKey :: ChildKey ( ChildKey :: IdDesc (
3409- ChildIdDetails {
3410- child_table,
3411- child_from,
3412- parent_join_column : parent_column,
3413- child_join_column : child_column,
3414- child_pk,
3415- child_br,
3416- child_at_block,
3417- } ,
3418- use_block_column,
3419- ) ) ) ,
3420- } ;
3382+
3383+ return Ok ( SortKey :: ChildKey ( ChildKey :: Id (
3384+ direction,
3385+ ChildIdDetails {
3386+ child_table,
3387+ child_from,
3388+ parent_join_column : parent_column,
3389+ child_join_column : child_column,
3390+ child_pk,
3391+ child_br,
3392+ child_at_block,
3393+ } ,
3394+ use_block_column,
3395+ ) ) ) ;
34213396 }
34223397
34233398 let child_table = child_table. child ( 1 ) ;
@@ -3750,13 +3725,11 @@ impl<'a> SortKey<'a> {
37503725 }
37513726 ChildKey :: ManyIdAsc ( _, UseBlockColumn :: No )
37523727 | ChildKey :: ManyIdDesc ( _, UseBlockColumn :: No ) => { /* nothing to do */ }
3753- ChildKey :: IdAsc ( child, UseBlockColumn :: Yes )
3754- | ChildKey :: IdDesc ( child, UseBlockColumn :: Yes ) => {
3728+ ChildKey :: Id ( _, child, UseBlockColumn :: Yes ) => {
37553729 out. push_sql ( ", " ) ;
37563730 child. child_br . walk_ast ( out. reborrow ( ) ) ?;
37573731 }
3758- ChildKey :: IdAsc ( _, UseBlockColumn :: No )
3759- | ChildKey :: IdDesc ( _, UseBlockColumn :: No ) => { /* nothing to do */ }
3732+ ChildKey :: Id ( _, _, UseBlockColumn :: No ) => { /* nothing to do */ }
37603733 }
37613734
37623735 if let SelectStatementLevel :: InnerStatement = select_statement_level {
@@ -3827,21 +3800,13 @@ impl<'a> SortKey<'a> {
38273800 SortKey :: multi_sort_id_expr ( children, Desc , * use_block_column, out)
38283801 }
38293802
3830- ChildKey :: IdAsc ( child, use_block_column) => {
3831- child. child_pk . walk_ast ( out. reborrow ( ) ) ?;
3832- if UseBlockColumn :: Yes == * use_block_column {
3833- out. push_sql ( ", " ) ;
3834- child. child_br . walk_ast ( out. reborrow ( ) ) ?;
3835- }
3836- Ok ( ( ) )
3837- }
3838- ChildKey :: IdDesc ( child, use_block_column) => {
3803+ ChildKey :: Id ( direction, child, use_block_column) => {
38393804 child. child_pk . walk_ast ( out. reborrow ( ) ) ?;
3840- out. push_sql ( " desc" ) ;
3805+ out. push_sql ( direction . as_sql ( ) ) ;
38413806 if UseBlockColumn :: Yes == * use_block_column {
38423807 out. push_sql ( ", " ) ;
38433808 child. child_br . walk_ast ( out. reborrow ( ) ) ?;
3844- out. push_sql ( " desc" ) ;
3809+ out. push_sql ( direction . as_sql ( ) ) ;
38453810 }
38463811 Ok ( ( ) )
38473812 }
@@ -4109,7 +4074,7 @@ impl<'a> SortKey<'a> {
41094074 ) ?;
41104075 }
41114076 }
4112- ChildKey :: IdAsc ( child , _ ) | ChildKey :: IdDesc ( child, _) => {
4077+ ChildKey :: Id ( _ , child, _) => {
41134078 add (
41144079 & child. child_from ,
41154080 & child. child_join_column ,
0 commit comments