Skip to content

Commit b6f7492

Browse files
author
Zoran Cvetkov
committed
cleanup
1 parent d178175 commit b6f7492

File tree

7 files changed

+14
-21
lines changed

7 files changed

+14
-21
lines changed

graph/src/components/store/write.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,30 +1017,29 @@ mod test {
10171017

10181018
let value = value.clone();
10191019
let key = THING_TYPE.parse_key("one").unwrap();
1020-
let vid = 0i64;
10211020
match value {
10221021
Ins(block) => EntityModification::Insert {
10231022
key,
1024-
data: Arc::new(entity! { SCHEMA => id: "one", count: block, vid: vid }),
1023+
data: Arc::new(entity! { SCHEMA => id: "one", count: block }),
10251024
block,
10261025
end: None,
10271026
},
10281027
Ovw(block) => EntityModification::Overwrite {
10291028
key,
1030-
data: Arc::new(entity! { SCHEMA => id: "one", count: block, vid: vid }),
1029+
data: Arc::new(entity! { SCHEMA => id: "one", count: block }),
10311030
block,
10321031
end: None,
10331032
},
10341033
Rem(block) => EntityModification::Remove { key, block },
10351034
InsC(block, end) => EntityModification::Insert {
10361035
key,
1037-
data: Arc::new(entity! { SCHEMA => id: "one", count: block, vid: vid }),
1036+
data: Arc::new(entity! { SCHEMA => id: "one", count: block }),
10381037
block,
10391038
end: Some(end),
10401039
},
10411040
OvwC(block, end) => EntityModification::Overwrite {
10421041
key,
1043-
data: Arc::new(entity! { SCHEMA => id: "one", count: block, vid: vid }),
1042+
data: Arc::new(entity! { SCHEMA => id: "one", count: block }),
10441043
block,
10451044
end: Some(end),
10461045
},

graph/src/data/store/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ impl Entity {
924924
self.0.insert("vid", value.into())
925925
}
926926

927-
/// Sets the VID if not set. Should be used only for tests.
927+
/// Sets the VID if it's not already set. Should be used only for tests.
928928
#[cfg(debug_assertions)]
929929
pub fn set_vid_if_empty(&mut self) {
930930
let vid = self.get("vid");
@@ -948,7 +948,7 @@ impl Entity {
948948
/// If a key only exists on one entity, the value from that entity is chosen.
949949
/// If a key is set to `Value::Null` in `update`, the key/value pair is removed.
950950
pub fn merge_remove_null_fields(&mut self, update: Entity) -> Result<(), InternError> {
951-
for (key, value) in update.into_iter() {
951+
for (key, value) in update.0.into_iter() {
952952
match value {
953953
Value::Null => self.0.remove(&key),
954954
_ => self.0.insert(&key, value)?,

store/postgres/src/relational_queries.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ impl EntityData {
540540
// block_range that `select *` pulls in but that we
541541
// don't care about here
542542
if key == "vid" {
543-
// VID is not in the input schema but we need it so deserialize it too
543+
// VID is not in the input schema but we need it, so deserialize it too
544544
match T::Value::from_column_value(&ColumnType::Int8, json) {
545545
Ok(value) if value.is_null() => None,
546546
Ok(value) => Some(Ok((Word::from("vid"), value))),

store/test-store/tests/chain/ethereum/manifest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ specVersion: 0.0.2
416416
msg
417417
);
418418

419-
let thing = entity! { schema => id: "datthing", vid: 1i64 };
419+
let thing = entity! { schema => id: "datthing" };
420420
test_store::insert_entities(
421421
&deployment,
422422
vec![(schema.entity_type("Thing").unwrap(), thing)],

store/test-store/tests/core/interfaces.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ async fn reference_interface_derived() {
202202
let query = "query { events { id transaction { id } } }";
203203

204204
let buy = ("BuyEvent", entity! { schema => id: "buy", vid: 0i64 });
205-
let sell1 = ("SellEvent", entity! { schema => id: "sell1", vid: 0i64 });
206-
let sell2 = ("SellEvent", entity! { schema => id: "sell2", vid: 1i64 });
205+
let sell1 = ("SellEvent", entity! { schema => id: "sell1", vid: 1i64 });
206+
let sell2 = ("SellEvent", entity! { schema => id: "sell2", vid: 2i64 });
207207
let gift = (
208208
"GiftEvent",
209209
entity! { schema => id: "gift", transaction: "txn" },

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub async fn insert(
8282
.map(|mut data| {
8383
let data_type = schema.entity_type("Data").unwrap();
8484
let key = data_type.key(data.id());
85-
let _ = data.set_vid_if_empty();
85+
data.set_vid_if_empty();
8686
EntityOperation::Set { data, key }
8787
})
8888
.collect();

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,6 @@ fn create_schema(conn: &mut PgConnection) -> Layout {
157157
.expect("Failed to create relational schema")
158158
}
159159

160-
fn scrub(entity: &Entity) -> Entity {
161-
let mut scrubbed = entity.clone();
162-
scrubbed.remove_null_fields();
163-
scrubbed
164-
}
165-
166160
macro_rules! assert_entity_eq {
167161
($left:expr, $right:expr) => {{
168162
let (left, right) = (&($left), &($right));
@@ -271,7 +265,7 @@ fn find() {
271265

272266
// Happy path: find existing entity
273267
let entity = find_entity(conn, layout, ID).unwrap();
274-
assert_entity_eq!(scrub(&BEEF_ENTITY), entity);
268+
assert_entity_eq!(BEEF_ENTITY.clone(), entity);
275269
assert!(CausalityRegion::from_entity(&entity) == CausalityRegion::ONCHAIN);
276270

277271
// Find non-existing entity
@@ -288,7 +282,7 @@ fn find_many() {
288282
const ID2: &str = "0xdeadbeef02";
289283
const NAME2: &str = "Moo";
290284
insert_thing(&mut conn, layout, ID, NAME, 0);
291-
insert_thing(&mut conn, layout, ID2, NAME2, 1);
285+
insert_thing(&mut conn, layout, ID2, NAME2, 0);
292286

293287
let mut id_map = BTreeMap::default();
294288
let ids = IdList::try_from_iter(
@@ -336,7 +330,7 @@ fn update() {
336330
.expect("Failed to read Thing[deadbeef]")
337331
.unwrap();
338332

339-
assert_entity_eq!(scrub(&entity), actual);
333+
assert_entity_eq!(entity, actual);
340334
});
341335
}
342336

0 commit comments

Comments
 (0)