@@ -2535,12 +2535,26 @@ pub struct ChildKeyDetails<'a> {
2535
2535
pub direction : & ' static str ,
2536
2536
}
2537
2537
2538
+ #[ derive( Debug , Clone ) ]
2539
+ pub struct ChildIdDetails < ' a > {
2540
+ /// Table representing the parent entity
2541
+ pub parent_table : & ' a Table ,
2542
+ /// Column in the parent table that stores the connection between the parent and the child
2543
+ pub parent_join_column : & ' a Column ,
2544
+ /// Table representing the child entity
2545
+ pub child_table : & ' a Table ,
2546
+ /// Column in the child table that stores the connection between the child and the parent
2547
+ pub child_join_column : & ' a Column ,
2548
+ /// Prefix for the child table
2549
+ pub prefix : String ,
2550
+ }
2551
+
2538
2552
#[ derive( Debug , Clone ) ]
2539
2553
pub enum ChildKey < ' a > {
2540
2554
Single ( ChildKeyDetails < ' a > ) ,
2541
2555
Many ( Vec < ChildKeyDetails < ' a > > ) ,
2542
- IdAsc ( ChildKeyDetails < ' a > , Option < BlockRangeColumn < ' a > > ) ,
2543
- IdDesc ( ChildKeyDetails < ' a > , Option < BlockRangeColumn < ' a > > ) ,
2556
+ IdAsc ( ChildIdDetails < ' a > , Option < BlockRangeColumn < ' a > > ) ,
2557
+ IdDesc ( ChildIdDetails < ' a > , Option < BlockRangeColumn < ' a > > ) ,
2544
2558
}
2545
2559
2546
2560
/// Convenience to pass the name of the column to order by around. If `name`
@@ -2733,28 +2747,22 @@ impl<'a> SortKey<'a> {
2733
2747
if sort_by_column. is_primary_key ( ) {
2734
2748
return match direction {
2735
2749
ASC => Ok ( SortKey :: ChildKey ( ChildKey :: IdAsc (
2736
- ChildKeyDetails {
2750
+ ChildIdDetails {
2737
2751
parent_table,
2738
2752
child_table,
2739
2753
parent_join_column : parent_column,
2740
2754
child_join_column : child_column,
2741
- /// Sort by this column
2742
- sort_by_column,
2743
2755
prefix : "cc" . to_string ( ) ,
2744
- direction,
2745
2756
} ,
2746
2757
br_column,
2747
2758
) ) ) ,
2748
2759
DESC => Ok ( SortKey :: ChildKey ( ChildKey :: IdDesc (
2749
- ChildKeyDetails {
2760
+ ChildIdDetails {
2750
2761
parent_table,
2751
2762
child_table,
2752
2763
parent_join_column : parent_column,
2753
2764
child_join_column : child_column,
2754
- /// Sort by this column
2755
- sort_by_column,
2756
2765
prefix : "cc" . to_string ( ) ,
2757
- direction,
2758
2766
} ,
2759
2767
br_column,
2760
2768
) ) ) ,
@@ -3276,17 +3284,7 @@ impl<'a> SortKey<'a> {
3276
3284
) ?;
3277
3285
}
3278
3286
}
3279
- ChildKey :: IdAsc ( child, _) => {
3280
- add (
3281
- block,
3282
- & child. child_table ,
3283
- & child. child_join_column ,
3284
- & child. parent_join_column ,
3285
- & child. prefix ,
3286
- out,
3287
- ) ?;
3288
- }
3289
- ChildKey :: IdDesc ( child, _) => {
3287
+ ChildKey :: IdAsc ( child, _) | ChildKey :: IdDesc ( child, _) => {
3290
3288
add (
3291
3289
block,
3292
3290
& child. child_table ,
0 commit comments