Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zorancv committed Jan 19, 2025
1 parent d178175 commit 640e7d1
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 20 deletions.
9 changes: 4 additions & 5 deletions graph/src/components/store/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,30 +1017,29 @@ mod test {

let value = value.clone();
let key = THING_TYPE.parse_key("one").unwrap();
let vid = 0i64;
match value {
Ins(block) => EntityModification::Insert {
key,
data: Arc::new(entity! { SCHEMA => id: "one", count: block, vid: vid }),
data: Arc::new(entity! { SCHEMA => id: "one", count: block }),
block,
end: None,
},
Ovw(block) => EntityModification::Overwrite {
key,
data: Arc::new(entity! { SCHEMA => id: "one", count: block, vid: vid }),
data: Arc::new(entity! { SCHEMA => id: "one", count: block }),
block,
end: None,
},
Rem(block) => EntityModification::Remove { key, block },
InsC(block, end) => EntityModification::Insert {
key,
data: Arc::new(entity! { SCHEMA => id: "one", count: block, vid: vid }),
data: Arc::new(entity! { SCHEMA => id: "one", count: block }),
block,
end: Some(end),
},
OvwC(block, end) => EntityModification::Overwrite {
key,
data: Arc::new(entity! { SCHEMA => id: "one", count: block, vid: vid }),
data: Arc::new(entity! { SCHEMA => id: "one", count: block }),
block,
end: Some(end),
},
Expand Down
4 changes: 2 additions & 2 deletions graph/src/data/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ impl Entity {
self.0.insert("vid", value.into())
}

/// Sets the VID if not set. Should be used only for tests.
/// Sets the VID if it's not already set. Should be used only for tests.
#[cfg(debug_assertions)]
pub fn set_vid_if_empty(&mut self) {
let vid = self.get("vid");
Expand All @@ -948,7 +948,7 @@ impl Entity {
/// If a key only exists on one entity, the value from that entity is chosen.
/// If a key is set to `Value::Null` in `update`, the key/value pair is removed.
pub fn merge_remove_null_fields(&mut self, update: Entity) -> Result<(), InternError> {
for (key, value) in update.into_iter() {
for (key, value) in update.0.into_iter() {
match value {
Value::Null => self.0.remove(&key),
_ => self.0.insert(&key, value)?,
Expand Down
2 changes: 1 addition & 1 deletion store/postgres/src/relational_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ impl EntityData {
// block_range that `select *` pulls in but that we
// don't care about here
if key == "vid" {
// VID is not in the input schema but we need it so deserialize it too
// VID is not in the input schema but we need it, so deserialize it too
match T::Value::from_column_value(&ColumnType::Int8, json) {
Ok(value) if value.is_null() => None,
Ok(value) => Some(Ok((Word::from("vid"), value))),
Expand Down
2 changes: 1 addition & 1 deletion store/test-store/tests/chain/ethereum/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ specVersion: 0.0.2
msg
);

let thing = entity! { schema => id: "datthing", vid: 1i64 };
let thing = entity! { schema => id: "datthing" };
test_store::insert_entities(
&deployment,
vec![(schema.entity_type("Thing").unwrap(), thing)],
Expand Down
4 changes: 2 additions & 2 deletions store/test-store/tests/core/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ async fn reference_interface_derived() {
let query = "query { events { id transaction { id } } }";

let buy = ("BuyEvent", entity! { schema => id: "buy", vid: 0i64 });
let sell1 = ("SellEvent", entity! { schema => id: "sell1", vid: 0i64 });
let sell2 = ("SellEvent", entity! { schema => id: "sell2", vid: 1i64 });
let sell1 = ("SellEvent", entity! { schema => id: "sell1", vid: 1i64 });
let sell2 = ("SellEvent", entity! { schema => id: "sell2", vid: 2i64 });
let gift = (
"GiftEvent",
entity! { schema => id: "gift", transaction: "txn" },
Expand Down
2 changes: 1 addition & 1 deletion store/test-store/tests/postgres/aggregation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub async fn insert(
.map(|mut data| {
let data_type = schema.entity_type("Data").unwrap();
let key = data_type.key(data.id());
let _ = data.set_vid_if_empty();
data.set_vid_if_empty();
EntityOperation::Set { data, key }
})
.collect();
Expand Down
10 changes: 2 additions & 8 deletions store/test-store/tests/postgres/relational_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ fn create_schema(conn: &mut PgConnection) -> Layout {
.expect("Failed to create relational schema")
}

fn scrub(entity: &Entity) -> Entity {
let mut scrubbed = entity.clone();
scrubbed.remove_null_fields();
scrubbed
}

macro_rules! assert_entity_eq {
($left:expr, $right:expr) => {{
let (left, right) = (&($left), &($right));
Expand Down Expand Up @@ -271,7 +265,7 @@ fn find() {

// Happy path: find existing entity
let entity = find_entity(conn, layout, ID).unwrap();
assert_entity_eq!(scrub(&BEEF_ENTITY), entity);
assert_entity_eq!(BEEF_ENTITY.clone(), entity);
assert!(CausalityRegion::from_entity(&entity) == CausalityRegion::ONCHAIN);

// Find non-existing entity
Expand Down Expand Up @@ -336,7 +330,7 @@ fn update() {
.expect("Failed to read Thing[deadbeef]")
.unwrap();

assert_entity_eq!(scrub(&entity), actual);
assert_entity_eq!(entity, actual);
});
}

Expand Down

0 comments on commit 640e7d1

Please sign in to comment.