Skip to content

Commit

Permalink
Fix inconsistent handling of piped edges (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysimonson committed Apr 27, 2023
1 parent 29703a5 commit 224626b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/src/memory/datastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,11 @@ impl<'a> Transaction<'a> for MemoryTransaction<'a> {
}));
Ok(Some(Box::new(iter.map(|e| Ok(e.clone())))))
} else {
Ok(None)
let iter = Vec::default().into_iter();
Ok(Some(Box::new(iter)))
}
} else {
Err(Error::NotIndexed)
Ok(None)
}
}

Expand Down
12 changes: 10 additions & 2 deletions lib/src/tests/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::collections::HashSet;

use super::util;
use crate::{
ijson, models, AllEdgeQuery, Database, Datastore, Edge, EdgeDirection, Error, QueryExt, SpecificEdgeQuery,
SpecificVertexQuery,
ijson, models, AllEdgeQuery, Database, Datastore, Edge, EdgeDirection, EdgeWithPropertyValueQuery, Error,
Identifier, QueryExt, SpecificEdgeQuery, SpecificVertexQuery,
};

use uuid::Uuid;
Expand Down Expand Up @@ -221,6 +221,14 @@ pub fn should_get_edges_piped<D: Datastore>(db: &Database<D>) -> Result<(), Erro
Ok(())
}

/// Test for a regression, see
/// https://github.com/indradb/indradb/issues/278#issuecomment-1515797381
pub fn should_delete_indexed_edge_with_property_value<D: Datastore>(db: &Database<D>) -> Result<(), Error> {
db.index_property(Identifier::new("k")?)?;
db.delete(EdgeWithPropertyValueQuery::new(Identifier::new("k")?, ijson!(null)))?;
Ok(())
}

fn check_edge_range(range: &[models::Edge], expected_outbound_id: Uuid, expected_length: usize) -> Result<(), Error> {
assert_eq!(range.len(), expected_length);
let mut covered_ids: HashSet<Uuid> = HashSet::new();
Expand Down
1 change: 1 addition & 0 deletions lib/src/tests/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ macro_rules! full_test_impl {
define_test!(should_get_edge_range, $code);
define_test!(should_get_edges, $code);
define_test!(should_get_edges_piped, $code);
define_test!(should_delete_indexed_edge_with_property_value, $code);

// Include queries
define_test!(should_get_nested_include_query, $code);
Expand Down

0 comments on commit 224626b

Please sign in to comment.