Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify result summary api #222

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 6 additions & 33 deletions lib/include/result_summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,18 @@
}

//
// next_or_summary
// next + finish

let mut stream = graph
.execute(query("CREATE (n:Node {prop: 'frobnicate'}) RETURN n"))
.await
.unwrap();

let Ok(Some(row)) = stream.next_or_summary().await else { panic!() };
assert!(row.row().is_some());
assert!(row.summary().is_none());
let Ok(Some(row)) = stream.next().await else { panic!() };
assert_item(row.to().unwrap());

assert_item(row.row().unwrap().to().unwrap());

let Ok(Some(row)) = stream.next_or_summary().await else { panic!() };
assert!(row.row().is_none());
assert!(row.summary().is_some());

assert_summary(row.summary().unwrap());


//
// as_items

let mut stream = graph
.execute(query("CREATE (n:Node {prop: 'frobnicate'}) RETURN n"))
.await
.unwrap();

let items = stream.as_items::<N>()
.try_collect::<Vec<_>>()
.await
.unwrap();

for item in items {
match item {
RowItem::Row(row) => assert_item(row),
RowItem::Summary(summary) => assert_summary(&summary),
}
}
let Ok(summary) = stream.finish().await else { panic!() };
assert_summary(&summary);


//
Expand All @@ -76,7 +49,7 @@
.await
.unwrap();

let Ok(Some(summary)) = stream.finish().await else { panic!() };
let Ok(summary) = stream.finish().await else { panic!() };

for item in items {
assert_item(item);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ pub use crate::errors::{
pub use crate::graph::{query, Graph};
pub use crate::query::{Query, QueryParameter};
pub use crate::row::{Node, Path, Point2D, Point3D, Relation, Row, UnboundedRelation};
pub use crate::stream::{DetachedRowStream, RowItem, RowStream};
pub use crate::stream::{DetachedRowStream, RowStream};
pub use crate::txn::Txn;
pub use crate::types::serde::{
DeError, EndNodeId, Id, Indices, Keys, Labels, Nodes, Offset, Relationships, StartNodeId,
Expand Down
Loading