Skip to content

Commit

Permalink
store: Handle is type 'Bytes' correctly for children type c
Browse files Browse the repository at this point in the history
We did not account for parent ids being `bytea` when generating queries for
children type c which only caused trouble when such entities were used in
interfaces.
  • Loading branch information
lutter committed Sep 7, 2022
1 parent 4c8254c commit 433614e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions store/postgres/src/relational_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,7 @@ impl ParentIds {
#[derive(Debug, Clone)]
enum TableLink<'a> {
Direct(&'a Column, ChildMultiplicity),
/// The `Table` is the parent table
Parent(&'a Table, ParentIds),
}

Expand Down Expand Up @@ -2190,6 +2191,7 @@ impl<'a> FilterWindow<'a> {

fn children_type_c(
&self,
parent_primary_key: &Column,
child_ids: &[Vec<Option<SafeString>>],
limit: ParentLimit<'_>,
block: BlockNumber,
Expand All @@ -2209,7 +2211,7 @@ impl<'a> FilterWindow<'a> {

out.push_sql("\n/* children_type_c */ from ");
out.push_sql("rows from (unnest(");
out.push_bind_param::<Array<Text>, _>(&self.ids)?;
parent_primary_key.bind_ids(&self.ids, out)?;
out.push_sql("), reduce_dim(");
self.table.primary_key().push_matrix(child_ids, out)?;
out.push_sql(")) as p(id, child_ids)");
Expand Down Expand Up @@ -2292,9 +2294,13 @@ impl<'a> FilterWindow<'a> {
}
}
}
TableLink::Parent(_, ParentIds::List(child_ids)) => {
self.children_type_c(child_ids, limit, block, &mut out)
}
TableLink::Parent(parent_table, ParentIds::List(child_ids)) => self.children_type_c(
parent_table.primary_key(),
child_ids,
limit,
block,
&mut out,
),
TableLink::Parent(_, ParentIds::Scalar(child_ids)) => {
self.child_type_d(child_ids, limit, block, &mut out)
}
Expand Down

0 comments on commit 433614e

Please sign in to comment.