Skip to content

Commit 23886da

Browse files
committed
Require less data
1 parent 1c02ed6 commit 23886da

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

store/postgres/src/relational_queries.rs

+19-21
Original file line numberDiff line numberDiff line change
@@ -2535,12 +2535,26 @@ pub struct ChildKeyDetails<'a> {
25352535
pub direction: &'static str,
25362536
}
25372537

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+
25382552
#[derive(Debug, Clone)]
25392553
pub enum ChildKey<'a> {
25402554
Single(ChildKeyDetails<'a>),
25412555
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>>),
25442558
}
25452559

25462560
/// Convenience to pass the name of the column to order by around. If `name`
@@ -2733,28 +2747,22 @@ impl<'a> SortKey<'a> {
27332747
if sort_by_column.is_primary_key() {
27342748
return match direction {
27352749
ASC => Ok(SortKey::ChildKey(ChildKey::IdAsc(
2736-
ChildKeyDetails {
2750+
ChildIdDetails {
27372751
parent_table,
27382752
child_table,
27392753
parent_join_column: parent_column,
27402754
child_join_column: child_column,
2741-
/// Sort by this column
2742-
sort_by_column,
27432755
prefix: "cc".to_string(),
2744-
direction,
27452756
},
27462757
br_column,
27472758
))),
27482759
DESC => Ok(SortKey::ChildKey(ChildKey::IdDesc(
2749-
ChildKeyDetails {
2760+
ChildIdDetails {
27502761
parent_table,
27512762
child_table,
27522763
parent_join_column: parent_column,
27532764
child_join_column: child_column,
2754-
/// Sort by this column
2755-
sort_by_column,
27562765
prefix: "cc".to_string(),
2757-
direction,
27582766
},
27592767
br_column,
27602768
))),
@@ -3276,17 +3284,7 @@ impl<'a> SortKey<'a> {
32763284
)?;
32773285
}
32783286
}
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, _) => {
32903288
add(
32913289
block,
32923290
&child.child_table,

0 commit comments

Comments
 (0)