Skip to content

Commit 4f220d6

Browse files
author
Zoran Cvetkov
committed
check does the entity need a vid
1 parent b107559 commit 4f220d6

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

graph/src/components/store/entity_cache.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -406,19 +406,23 @@ impl EntityCache {
406406
*write_capacity_remaining -= weight;
407407
}
408408

409-
// The next VID is based on a block number and a sequence within the block
410-
let vid = ((block as i64) << 32) + self.vid_seq as i64;
411-
self.vid_seq += 1;
409+
let is_object = key.entity_type.is_object_type();
410+
412411
let mut entity = entity;
413-
let old_vid = entity.set_vid(vid).expect("the vid should be set");
414-
// Make sure that there was no VID previously set for this entity.
415-
if let Some(ovid) = old_vid {
416-
bail!(
417-
"VID: {} of entity: {} with ID: {} was already present when set in EntityCache",
418-
ovid,
419-
key.entity_type,
420-
entity.id()
421-
);
412+
if self.strict_vid_order && is_object {
413+
// The next VID is based on a block number and a sequence within the block
414+
let vid = ((block as i64) << 32) + self.vid_seq as i64;
415+
self.vid_seq += 1;
416+
let old_vid = entity.set_vid(vid).expect("the vid should be set");
417+
// Make sure that there was no VID previously set for this entity.
418+
if let Some(ovid) = old_vid {
419+
bail!(
420+
"VID: {} of entity: {} with ID: {} was already present when set in EntityCache",
421+
ovid,
422+
key.entity_type,
423+
entity.id()
424+
);
425+
}
422426
}
423427

424428
self.entity_op(key.clone(), EntityOp::Update(entity));

store/postgres/src/relational_queries.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,11 @@ impl<'a> InsertRow<'a> {
22572257
}
22582258
let br_value = BlockRangeValue::new(table, row.block, row.end);
22592259
let causality_region = row.causality_region;
2260-
let vid = row.entity.vid();
2260+
let vid = if table.object.has_vid_seq() {
2261+
row.entity.vid()
2262+
} else {
2263+
0
2264+
};
22612265
Ok(Self {
22622266
values,
22632267
br_value,

0 commit comments

Comments
 (0)