Skip to content

Commit 385fd3f

Browse files
committed
Revert "graph, graphql, store: Fix ParentLink entries"
This reverts commit 906f5e6.
1 parent 215adc5 commit 385fd3f

File tree

4 files changed

+25
-36
lines changed

4 files changed

+25
-36
lines changed

graph/src/components/store/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ pub enum ParentLink {
461461
/// The parent stores the id of one child. The ith entry in the
462462
/// vector contains the id of the child of the parent with id
463463
/// `EntityWindow.ids[i]`
464-
Scalar(Vec<Option<String>>),
464+
Scalar(Vec<String>),
465465
}
466466

467467
/// How many children a parent can have when the child stores

graphql/src/store/prefetch.rs

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,10 @@ impl<'a> JoinCond<'a> {
296296
// those and the parent ids
297297
let (ids, child_ids): (Vec<_>, Vec<_>) = parents_by_id
298298
.into_iter()
299-
.map(|(id, node)| {
300-
(
301-
id,
302-
node.get(child_field)
303-
.and_then(|value| value.as_str().map(|s| s.to_string())),
304-
)
299+
.filter_map(|(id, node)| {
300+
node.get(child_field)
301+
.and_then(|value| value.as_str())
302+
.map(|child_id| (id, child_id.to_owned()))
305303
})
306304
.unzip();
307305

@@ -313,28 +311,25 @@ impl<'a> JoinCond<'a> {
313311
// parent ids
314312
let (ids, child_ids): (Vec<_>, Vec<_>) = parents_by_id
315313
.into_iter()
316-
.map(|(id, node)| {
317-
(
318-
id,
319-
node.get(child_field)
320-
.and_then(|value| match value {
321-
r::Value::List(values) => {
322-
let values: Vec<_> = values
323-
.iter()
324-
.filter_map(|value| {
325-
value.as_str().map(|value| value.to_owned())
326-
})
327-
.collect();
328-
if values.is_empty() {
329-
None
330-
} else {
331-
Some(values)
332-
}
314+
.filter_map(|(id, node)| {
315+
node.get(child_field)
316+
.and_then(|value| match value {
317+
r::Value::List(values) => {
318+
let values: Vec<_> = values
319+
.iter()
320+
.filter_map(|value| {
321+
value.as_str().map(|value| value.to_owned())
322+
})
323+
.collect();
324+
if values.is_empty() {
325+
None
326+
} else {
327+
Some(values)
333328
}
334-
_ => None,
335-
})
336-
.unwrap_or(Vec::new()),
337-
)
329+
}
330+
_ => None,
331+
})
332+
.map(|child_ids| (id, child_ids))
338333
})
339334
.unzip();
340335
(ids, ParentLink::List(child_ids))

store/postgres/src/relational_queries.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,13 +2103,7 @@ enum ParentIds {
21032103
impl ParentIds {
21042104
fn new(link: ParentLink) -> Self {
21052105
match link {
2106-
ParentLink::Scalar(child_ids) => {
2107-
// Remove `None` child ids; query generation doesn't require
2108-
// that parent and child ids are in strict 1:1
2109-
// correspondence
2110-
let child_ids = child_ids.into_iter().filter_map(|c| c).collect();
2111-
ParentIds::Scalar(child_ids)
2112-
}
2106+
ParentLink::Scalar(child_ids) => ParentIds::Scalar(child_ids),
21132107
ParentLink::List(child_ids) => {
21142108
// Postgres will only accept child_ids, which is a Vec<Vec<String>>
21152109
// if all Vec<String> are the same length. We therefore pad

store/test-store/tests/postgres/relational_bytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ fn query() {
555555
ids: vec![CHILD1.to_owned(), CHILD2.to_owned()],
556556
link: EntityLink::Parent(
557557
THING.clone(),
558-
ParentLink::Scalar(vec![Some(ROOT.to_owned()), Some(ROOT.to_owned())]),
558+
ParentLink::Scalar(vec![ROOT.to_owned(), ROOT.to_owned()]),
559559
),
560560
column_names: AttributeNames::All,
561561
}]);

0 commit comments

Comments
 (0)