diff --git a/grovedb/src/batch/mod.rs b/grovedb/src/batch/mod.rs index 8f275095..f6a4e7ea 100644 --- a/grovedb/src/batch/mod.rs +++ b/grovedb/src/batch/mod.rs @@ -380,27 +380,9 @@ impl fmt::Debug for GroveDbOp { self.key.visualize(key_drawer).unwrap(); let op_dbg = match &self.op { - Op::Insert { element } => match element { - Element::Item(..) => "Insert Item".to_string(), - Element::Reference(..) => "Insert Ref".to_string(), - Element::Tree(..) => "Insert Tree".to_string(), - Element::SumTree(..) => "Insert Sum Tree".to_string(), - Element::SumItem(..) => "Insert Sum Item".to_string(), - }, - Op::Replace { element } => match element { - Element::Item(..) => "Replace Item".to_string(), - Element::Reference(..) => "Replace Ref".to_string(), - Element::Tree(..) => "Replace Tree".to_string(), - Element::SumTree(..) => "Replace Sum Tree".to_string(), - Element::SumItem(..) => "Replace Sum Item".to_string(), - }, - Op::Patch { element, .. } => match element { - Element::Item(..) => "Patch Item".to_string(), - Element::Reference(..) => "Patch Ref".to_string(), - Element::Tree(..) => "Patch Tree".to_string(), - Element::SumTree(..) => "Patch Sum Tree".to_string(), - Element::SumItem(..) => "Patch Sum Item".to_string(), - }, + Op::Insert { element } => format!("Insert {:?}", element), + Op::Replace { element } => format!("Replace {:?}", element), + Op::Patch { element, .. } => format!("Patch {:?}", element), Op::RefreshReference { reference_path_type, max_reference_hop, diff --git a/grovedb/src/tests/query_tests.rs b/grovedb/src/tests/query_tests.rs index c8e53ff8..7d5fc680 100644 --- a/grovedb/src/tests/query_tests.rs +++ b/grovedb/src/tests/query_tests.rs @@ -2663,13 +2663,12 @@ fn test_query_b_depends_on_query_a() { fn test_prove_absent_path_with_intermediate_emtpy_tree() { // root // test_leaf (empty) - let mut grovedb = make_test_grovedb(); + let grovedb = make_test_grovedb(); // prove the absence of key "book" in ["test_leaf", "invalid"] let mut query = Query::new(); query.insert_key(b"book".to_vec()); - let mut path_query = - PathQuery::new_unsized(vec![TEST_LEAF.to_vec(), b"invalid".to_vec()], query); + let path_query = PathQuery::new_unsized(vec![TEST_LEAF.to_vec(), b"invalid".to_vec()], query); let proof = grovedb .prove_query(&path_query) diff --git a/grovedb/src/visualize.rs b/grovedb/src/visualize.rs index 3abbbfd0..6bba2f83 100644 --- a/grovedb/src/visualize.rs +++ b/grovedb/src/visualize.rs @@ -44,12 +44,24 @@ use crate::{ impl Visualize for Element { fn visualize(&self, mut drawer: Drawer) -> Result> { match self { - Element::Item(value, _) => { + Element::Item(value, flags) => { drawer.write(b"item: ")?; drawer = value.visualize(drawer)?; + + if let Some(f) = flags { + if !f.is_empty() { + drawer = f.visualize(drawer)?; + } + } } - Element::SumItem(value, _) => { + Element::SumItem(value, flags) => { drawer.write(format!("sum_item: {value}").as_bytes())?; + + if let Some(f) = flags { + if !f.is_empty() { + drawer = f.visualize(drawer)?; + } + } } Element::Reference(_ref, ..) => { drawer.write(b"ref")?; @@ -64,13 +76,26 @@ impl Visualize for Element { // } // drawer.write(b"]")?; } - Element::Tree(root_key, _) => { + Element::Tree(root_key, flags) => { drawer.write(b"tree: ")?; drawer = root_key.as_deref().visualize(drawer)?; + + if let Some(f) = flags { + if !f.is_empty() { + drawer = f.visualize(drawer)?; + } + } } - Element::SumTree(root_key, ..) => { + Element::SumTree(root_key, value, flags) => { drawer.write(b"sum_tree: ")?; drawer = root_key.as_deref().visualize(drawer)?; + drawer.write(format!(" {value}").as_bytes())?; + + if let Some(f) = flags { + if !f.is_empty() { + drawer = f.visualize(drawer)?; + } + } } } Ok(drawer)