Skip to content

Commit 2674b53

Browse files
author
Zoran Cvetkov
committed
comments and renames
1 parent ca5c704 commit 2674b53

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

graph/src/schema/entity_type.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,9 @@ impl EntityType {
151151
self.schema.is_object_type(self.atom)
152152
}
153153

154-
// Changes the way the VID field is generated. It used to be autoincrement. Now its
155-
// based on block number and the order of the entities in a block. The latter
156-
// represents the write order across all entity types in the subgraph.
157-
pub fn strict_vid_order(&self) -> bool {
154+
/// Whether the table for this entity type uses a sequence for the `vid` or whether
155+
/// `graph-node` sets them explicitly. See also [`InputSchema.strict_vid_order()`]
156+
pub fn has_vid_seq(&self) -> bool {
158157
// Currently the agregations entities don't have VIDs in insertion order
159158
self.schema.strict_vid_order() && self.is_object_type()
160159
}

graph/src/schema/input/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,10 @@ impl InputSchema {
15891589
Some(EntityType::new(self.cheap_clone(), obj_type.name))
15901590
}
15911591

1592+
/// How the values for the VID field are generated.
1593+
/// When this is `false`, this subgraph uses the old way of autoincrementing `vid` in the database.
1594+
/// When it is `true`, `graph-node` sets the `vid` explicitly to a number based on block number
1595+
/// and the order in which entities are written, and comparing by `vid` will order entities by that order.
15921596
pub fn strict_vid_order(&self) -> bool {
15931597
self.inner.spec_version >= SPEC_VERSION_1_3_0
15941598
}

store/postgres/src/relational/ddl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl Table {
116116
Ok(cols)
117117
}
118118

119-
let vid_type = if self.object.strict_vid_order() {
119+
let vid_type = if self.object.has_vid_seq() {
120120
"bigint"
121121
} else {
122122
"bigserial"

store/postgres/src/relational/prune.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl TablePair {
205205

206206
// Make sure the vid sequence continues from where it was in case
207207
// that we use autoincrementing order of the DB
208-
if !self.src.object.strict_vid_order() {
208+
if !self.src.object.has_vid_seq() {
209209
writeln!(
210210
query,
211211
"select setval('{dst_nsp}.{vid_seq}', nextval('{src_nsp}.{vid_seq}'));"

store/postgres/src/relational_queries.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,7 +2331,7 @@ impl<'a> InsertQuery<'a> {
23312331
if table.has_causality_region {
23322332
count += 1;
23332333
}
2334-
if table.object.strict_vid_order() {
2334+
if table.object.has_vid_seq() {
23352335
count += 1;
23362336
}
23372337
for column in table.columns.iter() {
@@ -2355,7 +2355,7 @@ impl<'a> QueryFragment<Pg> for InsertQuery<'a> {
23552355
let out = &mut out;
23562356
out.unsafe_to_cache_prepared();
23572357

2358-
let strict_vid_order = self.table.object.strict_vid_order();
2358+
let strict_vid_order = self.table.object.has_vid_seq();
23592359

23602360
// Construct a query
23612361
// insert into schema.table(column, ...)
@@ -4805,7 +4805,7 @@ impl<'a> QueryFragment<Pg> for CopyEntityBatchQuery<'a> {
48054805
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Pg>) -> QueryResult<()> {
48064806
out.unsafe_to_cache_prepared();
48074807

4808-
let strict_vid_order = self.src.object.strict_vid_order();
4808+
let strict_vid_order = self.src.object.has_vid_seq();
48094809

48104810
// Construct a query
48114811
// insert into {dst}({columns})

0 commit comments

Comments
 (0)